我正在尝试在 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 响应?