【发布时间】:2011-06-08 11:10:40
【问题描述】:
我正在尝试编写一个代码,它将能够通过 whois.domaintools.com 验证域。
但是读取 html 有一点问题,与 whois.domaintools.com/notregistereddomain.com 源代码不匹配。怎么了?它的问题是请求还是什么?实在不知道怎么解决。
import urllib2
def getPage():
url="http://whois.domaintools.com/notregistereddomain.com"
req = urllib2.Request(url)
try:
response = urllib2.urlopen(req)
return response.read()
except urllib2.HTTPError, error:
print "error: ", error.read()
a = error.read()
f = open("URL.txt", "a")
f.write(a)
f.close()
if __name__ == "__main__":
namesPage = getPage()
print namesPage
【问题讨论】: