欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

requests应用,代理

程序员文章站 2022-05-08 09:59:13
...

对于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)
相关标签: requests