解决 Python Web 代理的 DNSLookupFailedError 问题



我的代码如下:

https://github.com/T145/tphroxy/blob/master/mirror.py

https://github.com/T145/tphroxy/blob/master/transform_content.py

当访问某些网站时,我会收到以下错误:

Traceback (most recent call last):
  File " ... /mirror.py", line 108, in fetch_and_store
    response = urlfetch.fetch(mirrored_url)
  File " ... /google/appengine/api/urlfetch.py", line 293, in fetch
    return rpc.get_result()
  File " ... /google/appengine/api/apiproxy_stub_map.py", line 613, in get_result
    return self.__get_result_hook(self)
  File " ... /python27_lib/versions/1/google/appengine/api/urlfetch.py", line 449, in _get_fetch_result
    raise DNSLookupFailedError('DNS lookup failed for URL: ' + url)
DNSLookupFailedError: DNS lookup failed for URL: http://public/images/v6/btn_arrow_down_padded_white.png

我的猜测是特定的资产 url 模式没有通过代理正确匹配和发送,即 transform_content缺少模式。非常感谢任何有助于解决此问题的帮助!如果需要,我愿意使用任何替代库。

演示

编辑

我为 transform_content 添加了一个测试套件,我确信主要问题出在结果中的正则表达式上。如果您使用的是Windows,请py transform_content_test.py运行它以获取结果。

> DNS lookup failed for URL: http://public/... 请注意 URL 中缺少域(主机(部分,public字符串将被解析为域,这是无效的,导致您看到的错误。

URL 应类似于 http://<valid_domain>/public/... ,因此请检查构建该 URL 的代码。

您正在对 URL 进行相当多的字符串操作,检查所有可能的代码路径是否正常运行,我的猜测是有些没有按照您的期望执行。

相关内容

  • 没有找到相关文章

最新更新