How to configure proxies on Windows 11?

Viewed 95

When I try to grab some texts in the "https://nature.altmetric.com/details/114136890", my python meet the following problem.

requests.exceptions.ProxyError: HTTPSConnectionPool(host='nature.altmetric.com', port=443): 
Max retries exceeded with url: /details/114136890 (Caused by ProxyError('Your proxy appears to only use HTTP and not HTTPS, try changing your proxy URL to be HTTP. 
See: https://urllib3.readthedocs.io/en/1.26.x/advanced-usage.html#https-proxy-error-http-proxy', 
SSLError(SSLError(1, '[SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1129)'))))

Then I follow the suggestions in the recommended website.

import urllib.request
print(urllib.request.getproxies())'

My computer give the answers:

{'http': 'http://127.0.0.1:10809', 'https': 'https://127.0.0.1:10809', 'ftp': 'ftp://127.0.0.1:10809'}

The problem is happened in the 'https'. According to the document in "https://urllib3.readthedocs.io/en/1.26.x/advanced-usage.html#https-proxy-error-http-proxy" ,I should configure proxies on my operating system and change the https://... URL into http://.,but I have no idea about it.The problem have bothered me for hours.I am expected to receive suggestions.Thank you anyway!

1 Answers

What you should do is add such code in your script

Proxies = {
    "http": 'http://127.0.0.1:10809',
    "https": 'http://127.0.0.1:10809'
}

And then when requesting the target Url,use the type of code like this

page_text = requests.get(url=targetUrl,headers=headers,proxies=Proxies,verify=False).text
Related