如何在Windows上解决这个“NotImplementedError”urllib2 / gevent错误?

我正在尝试在
Windows XP上使用gevent修补urllib2打开一个url:

from gevent import monkey
monkey.patch_all()
import urllib2

opener = urllib2.build_opener()
request = urllib2.Request("http://www.google.com")
response = opener.open(request)

我在opener.open调用期间得到了这个异常:

File "C:\Python26\lib\site-packages\gevent\socket.py", line 768, in getaddrinfo
  sockaddr = (inet_ntop(AF_INET6, res), port, 0, 0)
File "C:\Python26\lib\site-packages\gevent\socket.py", line 133, in inet_ntop
  raise NotImplementedError('inet_ntop() is not available on this platform')
NotImplementedError: inet_ntop() is not available on this platform
<SERPScrapper at 0xbc0f60> failed with NotImplementedError

看看gevent socket.py源代码,它似乎与Windows上的IPV6有关…

有什么想法或主张来解决这个问题吗?

编辑:我没有得到其他网址的问题(即:http://www.bing.com).谷歌似乎正在使用IPV6.有没有办法强制IPV4响应?

最佳答案 请尝试向http://ipv4.google.com/提出请求.

点赞