Use the requests library to request url, this error will occur, the reason is:
The server is overloaded, and no more links can be established. There are 4 possibilities:
- Too many http connections are not closed.
- The machine’s memory is insufficient.
- Another possibility is that the IP is blocked by the target website due to the high request frequency
- The requested URL address is wrong
Solution:
1. increase the number of retry connections
requests.adapters.DEFAULT_RETRIES = 5
2. close redundant connections
requests uses the urllib3 library, the default http connection is keep-alive, requests set False to close.
Operation method:
s = requests.session()
s.keep_alive = False