Get the App
SLTechnology News&Howtos  ›  Network Security  › 

Example of python using IP Agent and error Resolution

Shulou Source: shulou.com Published: 2022-06-01 04:30:38 10月05日 Update

Code examples

#-*-coding:utf-8-*-import requestsheader = {'User-Agent':' Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36'} proxy_ip = {'https':' https://115.28.148.137:8118'}html = requests.get ("http://www.baidu.com", headers=header, proxies=proxy_ip) print htmlprint html.text

Second, you can change the proxy IP by modifying the address of the proxy IP server of the proxy_ip parameter.

Third, error warning

Requests.exceptions.ProxyError: HTTPSConnectionPool (host='www.baidu.com', port=443): Max retries exceeded with url: / (Caused by ProxyError ('Cannot connect to proxy.', error (10054,'))

There are generally two reasons for errors:

1. The ip proxy server cannot be used properly.

2. The protocol used by the IP agent is abnormal, for example, http:// and https:// cannot be written wrong.

If it is a http proxy server, it is written as follows:

Proxy_ip = {'http':' http://115.28.148.137:8118'}

If it is a https proxy server, it is written as follows:

Proxy_ip = {'https':' https://115.28.148.137:8118'}

Tags: Agent server service sample code writing reason parameter address utf-8 prompt method Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux Shulou Tech Info MySQL MariaDB Microsoft