0
我想开发python脚本来从domaintools.com托管公司信息,下面是我的脚本。 somthing这个认证部分错误,它返回403错误。用户身份验证whois.domaintools.com python脚本
domain_tools_url = 'https://secure.domaintools.com/log-in/'
username = '[email protected]'
password = 'password'
sys.path.append("./BeautifulSoup")
passman = urllib2.HTTPPasswordMgrWithDefaultRealm()
passman.add_password(None, domain_tools_url, username, password)
authhandler = urllib2.HTTPBasicAuthHandler(passman)
opener=urllib2.build_opener(authhandler, urllib2.HTTPHandler(debuglevel=0))
opener.addheaders = [('User-agent', 'Mozilla/5.0')]
url = "http://whois.domaintools.com/62.75.xxx.xxx"
page = opener.open(url)
可我知道如何解决这个问题,
感谢提前:)
['requests'(http://docs.python-requests.org/en/latest/)使这个要好很多 - 可能是值得一试。基本身份验证只是'requests.get('http://example.com',auth =('user','pass'))' –
嗨@AlexL,感谢您的回放。我已经安装了请求lib,并且我已经运行了脚本,它返回[Response 200] In [6]:requests.get(domain_tools_url,auth =(username,password)) Out [6]: then我如何处理这个URL =“http://whois.domaintools.com/62.75.xxx.xxx” –
AGR
认证后,它返回403响应'在[9]:requests.get(“http://whois.domaintools。 com/62.75.xxx.xxx“,auth =(username,password)) Out [9]: In [10]:requests.post(”http://whois.domaintools.com /62.75.xxx.xxx“) 输出[10]:<响应[403]>' –
AGR