requests_xcdl(requests_西刺代理)
程序员文章站
2022-07-13 13:00:13
...
import requests
url = 'http://www.xicidaili.com'
# <!-- 添加proxy -->
proxy = {
'http':'http://root:[email protected]:8118'
}
# <!-- 添加 headers -->
headers = {
'User-Agent':'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36'
}
# <!-- 调用requests,得到response -->
response = requests.get(url,headers=headers,proxies=proxy)
print(response.text)
with open('xicidaili.html','wb') as f:
f.write(response.content)
上一篇: Neural Network
下一篇: requests_猫眼电影