标签:html content 内容 改变 mozilla win chrome get pre
如果不改变header,往往只能获取到很少一部分的content。所以我们要改变header
import requests
respones = requests.get("https://www.baidu.com")
print(respones.status_code)
print(respones.headers)
print(respones.request.headers)
print(respones.content.decode())
print("更改headers后")
headers1 = {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) App1eWebKit/537.36 (KHTML; like Gecko) Chrome/83.0.4103.116 Safari/537.36"}
respones1 = requests.get("https://www.baidu.com",headers = headers1)
print(respones1.content.decode())
结果内容有很多,不贴上来了
标签:html content 内容 改变 mozilla win chrome get pre
原文地址:https://www.cnblogs.com/SunChuangYu/p/13229523.html