mechanize python XE #13
def retDomains(ip):
# find parked domains by ip from Hurricane Electric, can use other source
# may be duplicate with get_parked(data)
domains = []
try:
url = "http://bgp.he.net/ip/" + ip + "#_dns"
userAgent = [('User-agent','Mozilla/5.0 (X11; U; '+\
'Linux 2.4.2-2 i586; en-US; m18) Gecko/20010131 Netscape6/6.01')]
browser = mechanize.Browser()
browser.addheaders = userAgent
page = browser.open(url)
html = page.read()
link_finder = re.compile('href="(.*?)"')
links = link_finder.findall(html)
for i in range (0, len(links)):
if links[i].find('/dns/') == 0:
domains.append(links[i][5:])
return domains
except:
return domains