Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/319.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请求失败_Python_Proxy_Python Requests_Router - Fatal编程技术网

在路由器后面使用代理时,python请求失败

在路由器后面使用代理时,python请求失败,python,proxy,python-requests,router,Python,Proxy,Python Requests,Router,我的代码如下: import requests proxies = {'http':'ip:port'} r = requests.get('http://example.com', proxies = proxies) 当我在一台具有唯一ip地址的PC上运行此代码时,它工作正常, 但当我在路由器后面的PC上运行此代码时,它无法得到任何响应。 检查代理服务器后,我发现该连接不在代理服务器的日志中 我想不出来,请帮忙,谢谢 在@MilkeyMouse的帮助下,我将代码更改为: proxies =

我的代码如下:

import requests
proxies = {'http':'ip:port'}
r = requests.get('http://example.com', proxies = proxies)
当我在一台具有唯一ip地址的PC上运行此代码时,它工作正常, 但当我在路由器后面的PC上运行此代码时,它无法得到任何响应。 检查代理服务器后,我发现该连接不在代理服务器的日志中

我想不出来,请帮忙,谢谢

在@MilkeyMouse的帮助下,我将代码更改为:

proxies = {'http':'http://ip:port'}

但它仍然不起作用。

由于请求2.0.0,您需要向代理添加一个方案。见:


请注意代理URL之前的
http://

谢谢您的回答,我尝试了这个,但仍然不起作用。
import requests

proxies = {
  "http": "http://10.10.1.10:3128",
  "https": "http://10.10.1.10:1080",
}

requests.get("http://example.org", proxies=proxies)