Python Reptile use fixed proxy IP

Purchase of fixed IP agents are generally required to account password, use the Internet to find several methods, but are being given, therefore, I wanted this awkward, if everyone gets a good way to hope.

'''
遇到问题没人解答?小编创建了一个Python学习交流QQ群:579817333 
寻找有志同道合的小伙伴,互帮互助,群里还有不错的视频学习教程和PDF电子书!
'''
import requests
from requests.auth import HTTPBasicAuth

proxy = {
    'http': 'http://ip:port',
    'https': 'https://ip:port8'
}
head = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) '
                  'Chrome/50.0.2661.102 Safari/537.36',
    'Connection': 'keep-alive',
    'Proxy-Authorization': '...' # 在浏览器中获取此值
}
p = requests.get('http://icanhazip.com', headers=head)
print(p.content.decode('utf-8'))

----------------------------------------- The following is a method of obtaining Proxy-Authorization - --------------------------------------------------

First of all, it is to get in the Proxy-Authorization headers in

Use the Chrome browser, set the proxy ip

Here Insert Picture Description
Here Insert Picture Description
Here Insert Picture Description
Then click OK

Open a new web page, feel free to log in to a website
Here Insert Picture Description
Once logged in, visit http://127.0.0.1
Here Insert Picture Description
added scrapy of middleware:

'''
遇到问题没人解答?小编创建了一个Python学习交流QQ群:579817333 
寻找有志同道合的小伙伴,互帮互助,群里还有不错的视频学习教程和PDF电子书!
'''
request.meta['proxy'] = "http://ip:port"

# 添加Proxy-Authorization对应得值,添加在请求的headers中
request.headers['Proxy-Authorization'] = 'Basic ...........'

Such agents will be fixed to the ~ ip

Published 35 original articles · won praise 2 · views 10000 +

Guess you like

Origin blog.csdn.net/qdPython/article/details/104040465