requests应用,代理

对于requests包的调用

import requests

url = 'http://www.xicidaili.com'

proxy = {
    'http':'http://root:[email protected]:8118'
}
user_agent = 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.62 Safari/537.36'

headers = {
    'User-Agent':user_agent
}

response = requests.get(url,headers=headers,proxies=proxy)
print(response.text)

猜你喜欢

转载自blog.csdn.net/qq_41847171/article/details/81711533