第一個接口,查詢ip地址的地理信息接口:
r'http://api.ipinfodb.com//v2/ip_query.php?key=5eb5b4de91741e2e4b98748989dc84f3236b55f6dd38aa689921884867536f36&ip={}&output=json&timezone=false'
獲得子域名信息,google接口:
self.subdomainurl=r'https://ajax.googleapis.com/ajax/services/search/web?v=1.0&start={}&rsz=8&q=site:{}'
def getsubdomain(self):
for n in range(1,200,8):
request = urllib2.Request(self.subdomainurl.format(n,self.domain[self.domain.index('.')+1:]), None, {'Referer': 'http://www.baidu.com'})
try:info=simplejson.load(urllib2.urlopen(request))['responseData']['results']
except Exception as err:break
for i in info:
for l in i:
if l=='url':
self.subdomain.append( up(i[l]).netloc )
self.subdomain=list(set(self.subdomain))