Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/356.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 无法在mechanize.browser中成功设置代理_Python_Browser_Proxy_Mechanize_Mechanize Python - Fatal编程技术网

Python 无法在mechanize.browser中成功设置代理

Python 无法在mechanize.browser中成功设置代理,python,browser,proxy,mechanize,mechanize-python,Python,Browser,Proxy,Mechanize,Mechanize Python,我正在编写一个应用程序,它从电影数据库中检索数据。为了达到同样的效果,我使用了BeautifulSoup和Mechanize 因此,在通过以下方式将代理设置为时: 选择1: br.set_proxies({"http": "tim:abc1234@localhost:3128"}) br.set_proxies({'http':'localhost', 'https':'localhost'}) br.set_proxies( {"http

我正在编写一个应用程序,它从电影数据库中检索数据。为了达到同样的效果,我使用了BeautifulSoup和Mechanize

因此,在通过以下方式将代理设置为时:


选择1:

br.set_proxies({"http": "tim:abc1234@localhost:3128"})
br.set_proxies({'http':'localhost',
                    'https':'localhost'})
br.set_proxies(
     {"http": "tim:password@myproxy.example.com:3128",
      "ftp": "proxy.example.com"})
O/p

URLError: urlopen error [Errno 111] Connection refused
httperror_seek_wrapper: HTTP Error 500: Internal Server Error
URLError: urlopen error [Errno -2] Name or service not known

选择2:

br.set_proxies({"http": "tim:abc1234@localhost:3128"})
br.set_proxies({'http':'localhost',
                    'https':'localhost'})
br.set_proxies(
     {"http": "tim:password@myproxy.example.com:3128",
      "ftp": "proxy.example.com"})
O/p

URLError: urlopen error [Errno 111] Connection refused
httperror_seek_wrapper: HTTP Error 500: Internal Server Error
URLError: urlopen error [Errno -2] Name or service not known

选择3:

br.set_proxies({"http": "tim:abc1234@localhost:3128"})
br.set_proxies({'http':'localhost',
                    'https':'localhost'})
br.set_proxies(
     {"http": "tim:password@myproxy.example.com:3128",
      "ftp": "proxy.example.com"})
O/p

URLError: urlopen error [Errno 111] Connection refused
httperror_seek_wrapper: HTTP Error 500: Internal Server Error
URLError: urlopen error [Errno -2] Name or service not known

参考文件:

尽管遵循上述参考链接,我仍然无法正确设置代理。
任何潜在客户都将不胜感激。

首先,您需要工作代理服务器或工作代理服务器的地址。似乎你用地址来代替不工作的代理或不存在的代理服务器。@furas,ohh…我想也可以不用地址,通过某种虚拟代理。然而,你能帮我做一个有效的代理吗?如何做到这一点?有些页面上有免费的代理服务器列表,例如,但它们通常不起作用,并且您需要测试许多url。对于测试请求(要查看标头、cookie等中的内容,我使用本地代理服务器或