Home > Article > Backend Development > Solution: urllib3 ProxySchemeUnknown(proxy.scheme)
The ProxySchemeUnknown(proxy.scheme) error of urllib3 is usually caused by the use of an unsupported proxy protocol. In this case, urllib3 does not recognize the protocol type of the proxy server and therefore cannot use the proxy for the network connection. To resolve this issue, you need to make sure you are using a supported proxy protocol such as Http or https.
To resolve this issue, You need to make sure you use a supported proxy protocol, such as HTTP or HTTPS.
You can solve this problem by setting the proxy parameters of urllib3.
If you are using http proxy, the code example is as follows:
import urllib3 http = urllib3.PoolManager() proxy = urllib3.ProxyManager('http://proxy.server:3128') r = proxy.request('GET', 'http://httpbin.org/ip') print(r.data)
If you are using https proxy, the code example is as follows:
import urllib3 https = urllib3.PoolManager() proxy = urllib3.ProxyManager('https://proxy.server:3128') r = proxy.request('GET', 'https://httpbin.org/ip') print(r.data)
If you are using a third-party library or framework, you should check their documentation for more detailed information.
In addition, it should be noted that using a proxy requires authentication of the proxy server. If authentication is required, the user name and password need to be passed in when creating the proxy object.
Yes, if you need to use username and password to authenticate the proxy, you can use urllib3's ProxyManager class and pass in the username and password to set up authentication.
The code example is as follows:
import urllib3 proxy = urllib3.ProxyManager('http://proxy.server:3128', proxy_username='username', proxy_passWord='password') r = proxy.request('GET', 'http://httpbin.org/ip') print(r.data)
or
import urllib3 proxy = urllib3.ProxyManager('https://proxy.server:3128', proxy_username='username', proxy_password='password') r = proxy.request('GET', 'https://httpbin.org/ip') print(r.data)
If you are using a third-party library or framework, you should check their documentation for more detailed information.
The above is the detailed content of Solution: urllib3 ProxySchemeUnknown(proxy.scheme). For more information, please follow other related articles on the PHP Chinese website!