Small knowledge, big challenge! This article is participating in the creation activity of “Essential Tips for Programmers”

At the same time, I participated in the “Digitalstar Project” to win the creative gift package and challenge the creative incentive money

I am my cousin, a lifelong Python learner, data analysis enthusiast, and cat lover

This series will record some problems and solutions I have encountered in programming, and will be directly titled with errors encountered, so that it is more convenient for other learners to search for solutions to the problems in the browser. You are also welcome to communicate more in the comments and comments area, and talk about your own understanding or problems.

Such as unpleasant – requests. Exceptions. ProxyError is a good example.

【2021.8.27 update 】 Thanks to femtosecond Consciousness’s simple solution in the comments section, simply add the following code to your code:

# Don't bother at all. There are two ways:
# Method 1:
session = requests.Session()
session.trust_env = False
response = session.get('http://ff2.pw') 

# method 2 :(multiple playtests can directly solve this problem)
proxies = { "http": None."https": None}
requests.get("http://ff2.pw", proxies=proxies)

You can bypass the system Settings of the proxy
Copy the code

The following content is my previous solution to the problem, you can also refer to.

If you think the article is helpful, you can give the blogger a “like”. Thank you.

Can you bear to see such mistakes?

Small problem, you might say… But this has been troubling xiaobian all afternoon, let’s see how xiaobian solved it.

I thought it was a module problem at first, and then WROTE a test code by myself. I simply requested Baidu Music with request.

After running, sure enough, there is still this problem:

raise ProxyError(e, request=request)
requests.exceptions.ProxyError: HTTPConnectionPool(host='127.0.0.1', port=8087): 
Max retries exceeded with url: http://music.baidu.com/search?key=%E6%9D%8E%E5%81%A5
(Caused by ProxyError('Cannot connect to proxy.', NewConnectionError('
      
       : Failed to establish a new connection: [WinError 10061] Failed to connect because the target computer actively rejected it. '
      ))),Copy the code

Since feel is the module out of the problem, then uninstall reinstall it ~

Maya, unloading is very normal, but this installation, damn, a little scary…But, I finally noticed a problem, Proxy == Proxy, could it be the network problem, so xiaobian immediately cut off the network, connected to the mobile phone hotspot, and then cheerfully run the program again, sure enough, it still failed.

So what can we do, baidu, there is no relevant introduction, or just look at the error message, again notice the word proxy, like, we would use this word over the wall, since it is not the network itself, proxy, proxy, proxy… oh, proxy Settings, I found the problem quickly ran to Settings -> Network and INTERNET-> proxy, a look, scared me:No wonder I can’t access it locally, it turns out you are a small evil, shut down the proxy, install the module again, run the code, finally all the way smoothly, haha.

I am my cousin, a lifelong Python learner, data analysis enthusiast, and cat lover