python - pycurl 上的 DNS_SERVERS

标签 python python-2.7

我正在尝试使用 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/

相关文章:

python - python中的对数插值

python - 是否可以更改 firestore 中的文档 ID?

python - pymongo 按日期时间查询

ios - 使用 NAPALM 遍历开关列表

python - 查找pip包: pkg_resources specify custom target directory

python - `pip --allow-external` 的安全考虑

python - 根据时间戳过滤相似的行作为数据帧中的索引

python - 根据复杂条件对 Pandas DataFrame 中的行进行分组

python - 使用 heapq 函数 'nlargest' 在 python 中查找 FFT 的峰值及其对应的频率

python - 如何在寻宝游戏中将积分添加到总积分中?