Python Proxy type description

Source: Internet
Author: User

Environment Python 2.7python proxy type selection python proxy settings are usually as follows:
= {  "http""http://10.10.1.10:3128",  "https""http://10.10.1.10:1080",}

In HTTP and HTTPS two types, the HTTPS type of IP must correspond to such as: "https": "https ...", such as: "http": "https ..." this setting is wrong.

Test code example, the main following 4 kinds of situations: 1.requests Library Agent code into the following:
import= {"http""http://122.114.31.177:808"}  # 1. 成功= {"http""https://110.73.50.236:8123"# 2. 失败= {"https""http://122.114.31.177:808"}  #  3. 成功= {"https""https://110.73.50.236:8123"#  4. 失败= requests.get("http://www.baidu.com", proxies=proxies)print# 检测响应
The 2.urllib library Proxy code is as follows:
import= {"http""http://122.114.31.177:808"}  # 1. 成功= {"http""https://110.73.50.236:8123"# 2. 失败= {"https""http://122.114.31.177:808"}  #  3. 成功= {"https""https://110.73.50.236:8123"#  4. 失败= urllib.urlopen("http://www.baidu.com",proxies=proxies)print# 检测响应
Summarize

In order to avoid errors, we usually only need to set the HTTPS proxy type at the beginning, so that HTTP and HTTP types of IP can be proxied successfully.

Python Proxy type description

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.