Google


Monday, May 24, 2010

Giving away email addresses

Many people are aware that they increase spam by posting their email address online, they try to circumvent that by writing their email like me at gmail dot com. But the Python code below shows how to retrieve the email address from a string (even if people use brackets etc). So be cautious.

 
                text2=text.lower()
                text2=text2.replace(' dot ','.')
                text2=text2.replace(' (dot) ','.')
                text2=text2.replace('(dot)','.')
                text2=text2.replace(' [dot] ','.')
                text2=text2.replace('[dot]','.')
                text2=text2.replace(' {dot} ','.')
                text2=text2.replace('{dot}','.')
                text2=text2.replace(' at ','@')
                text2=text2.replace(' (at) ','@')
                text2=text2.replace('(at)','@')
                text2=text2.replace(' [at] ','@')
                text2=text2.replace('[at]','@')
                text2=text2.replace(' {at} ','@')
                text2=text2.replace('{at}','@')
                #now put into list
                text3=text2.split()
                for w in text3:
                    if w.find('@')>0 and w.find('.')>0:
                        if w.rfind('@') is not w.find('@'): #in case of 2 at
                            email=w[w.find('@')+1:]
                        else:
                            email=w

No comments: