+ -
当前位置:首页 → 问答吧 → Python + IIS7 + urllib2.open 失败

Python + IIS7 + urllib2.open 失败

时间:2010-10-20

来源:互联网

Python code

cookie = cookielib.CookieJar()
httpcookie = urllib2.HTTPCookieProcessor(cookie)
opener = urllib2.build_opener(httpcookie)
opener.addheaders=[('User-agen','Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.10) Gecko/20100914 Firefox/3.6.10')]
opener.addheaders=[('Referer','http://www.google.com')]
urllib2.install_opener(opener)

opener.open('http://www.google.com/')



IIS7执行到opener.open('http://www.google.com/') 失败,但从命令行执行成功。
urllib2.URLError: <urlopen error [Errno 11004] getaddrinfo failed>

什么原因,怎么解决呢?

作者: myblind   发布时间: 2010-10-20

关注,帮顶。。。。

作者: insisted_search   发布时间: 2010-10-22