How to: Using Python and Google to find hundreds of e-mail adresses

Who never received lots of unwanted messages on their e-mail? Certainly, few of us. You probably know it, you should never leave your email address in a web page. To understand why, I propose you to study this small Python script, which will scan the Google search for e-mail addresses. You may be surprised by how much results it will get.

Please note that this article is only a proof of concept and it may only be used for studying and learn how easily spammers can retrieves e-mail adresses by using Google and a simple Python script.
For those to whom the idea would cross the mind, remember that Christopher William Smith, often reffered as the king of spam, has recently been sentenced to 30 years of jail…

Well, enough discussion, let’s see what we are interested to know the code itself:


import sys
import re
import string
import httplib
import urllib2
import re

def StripTags(text):
    finished = 0
    while not finished:
        finished = 1
        start = text.find("<")
        if start >= 0:
            stop = text[start:].find(">")
            if stop >= 0:
                text = text[:start] + text[start+stop+1:]
                finished = 0
    return text

if len(sys.argv) != 2:
        print "\ : Find hundreds of e-mail adresses on Google.\n"
        print "\nUsage : ./ \n"
        print "\nexemple: ./ \n"

page_counter = 0
    while page_counter <400:
        results = ''+str(domain_name)+'&hl=en&lr=&ie=UTF-8&start=' + repr(page_counter) + '&sa=N'
        request = urllib2.Request(results)
        request.add_header('User-Agent','Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0)')
        opener = urllib2.build_opener()
        text =
        emails = (re.findall('([\w\.\-]+@'+domain_name+')',StripTags(text)))
        for email in emails:
        page_counter = page_counter +10
except IOError:
    print "No result found!"+""
    print "\n\n+++++++++++++++++++++++++++++++++++++++++++++++++++++"+""
    print "+ Results:"+""
    print "+++++++++++++++++++++++++++++++++++++++++++++++++++++\n\n"+""

    while page_counter_web >400 :
        results_web = ''+str(domain_name)+'&hl=en&lr=&ie=UTF-8&start=' + repr(page_counter_web) + '&sa=N'
        request_web = urllib2.Request(results_web)
        request_web.add_header('User-Agent','Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0)')
        opener_web = urllib2.build_opener()
        text =
        emails_web = (re.findall('([\w\.\-]+@'+domain_name+')',StripTags(text)))
        for email_web in emails_web:
        page_counter_web = page_counter_web +10

except IOError:
    print "No results found!"+""
for uniq_emails_web in d.keys():
    print uniq_emails_web+""

This command line program should be launched this way (assuming you named the file


It’s impressing to see how many e-mail adresses you can find with only 67 lines of code!