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
Then click OK
Open a new web page, feel free to log in to a website
Once logged in, visit http://127.0.0.1
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