Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/298.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请求模块在尝试访问HTTPS站点时不使用代理_Python_Python 3.x_Https_Proxy_Python Requests - Fatal编程技术网

Python请求模块在尝试访问HTTPS站点时不使用代理

Python请求模块在尝试访问HTTPS站点时不使用代理,python,python-3.x,https,proxy,python-requests,Python,Python 3.x,Https,Proxy,Python Requests,我正在尝试使用高级代理ip连接到使用请求模块的网站,但它不适用于“https”网站 import requests from requests.auth import HTTPProxyAuth auth=HTTPProxyAuth('username','password') proxies={ 'http':'http://xxx.xxx.x.xxx:8080/', 'https':'http://xxx.xxx.x.xxx:8080/' } print(requests.get('http

我正在尝试使用高级代理ip连接到使用请求模块的网站,但它不适用于“https”网站

import requests
from requests.auth import HTTPProxyAuth
auth=HTTPProxyAuth('username','password')
proxies={
'http':'http://xxx.xxx.x.xxx:8080/',
'https':'http://xxx.xxx.x.xxx:8080/'
}
print(requests.get('https://www.google.com',proxies=proxies,auth=auth).status_code)
将引发以下错误:

raise ProxyError(e, request=request)
requests.exceptions.ProxyError: HTTPSConnectionPool(host='www.google.com',port=443): Max retries exceeded with url: / (Caused by ProxyError('Cannot connect to proxy.', OSError('Tunnel connection failed: 407 Proxy Authentication Required')))
注意:我试过使用各种各样的猴子补丁,它们甚至在7年前就建议使用Digest Auth,但它们似乎都不起作用

编辑1:

我不是在用电脑http://username@密码:ip:用于使用代理的端口/格式,因为我的用户名包含“@”,这会导致分析错误


提前谢谢:)

我想你可以用这个

http://username@password:ip:port/
您提到您的密码由特殊字符组成

“@”可以替换为“%40”

比如说,

"Pass@word'可以替换为'Pass%40word'

如果您在密码中输入更多特殊字符,以下数据可能会有所帮助

'@' = '%40'
'%' ='%25'
'#' = '%23'
'@' = '%40'
':' = '%3a'
';' = '%3b'
'?' = '%3f'
'$' = '%24'
'!' = '%21'
'/' = '%2f'
'\' = '%27'
'"' = '%22'