我正在尝试使用 pycurl 使用不同的解析器下载测试页面。
>>> pycurl.version
'PycURL/7.19.3.1 libcurl/7.35.0 WinSSL'
我尝试过:
c = pycurl.Curl()
c.setopt(c.DNS_SERVERS, '1.2.3.4')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
pycurl.error: (4, '')
这种情况在 Linux 和 Windows 上同样发生。我究竟做错了什么?
我可以在 urllib2 中使用不同的解析器吗?
最佳答案
来自http://curl.haxx.se/libcurl/c/libcurl-errors.html
错误4
CURLE_NOT_BUILT_IN (4)
A requested feature, protocol or option was not found built-in in this libcurl due to a build-time decision. This means that a feature or option was not enabled or explicitly disabled when libcurl was built and in order to get it to function you have to get a rebuilt libcurl.
我的猜测是,底层 libcurl c 库未使用包含的 c-ares 库进行编译。
要解决此问题,可能需要自己编译 libcurl 并在配置脚本中启用 c-ares。
urllib2 可能是一个选项,请参阅 Tell urllib2 to use custom DNS
关于python - pycurl 上的 DNS_SERVERS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24121121/