Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Example of python using IP Agent and error Resolution

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

Shulou(Shulou.com)06/01 Report--

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'}

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Network Security

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report