Python 获取网页数据

首次发布:2023-06-17
1
2
3
4
5
6
7
8
9
10
#pip install requests  安装第三方库
import requests
 
#伪装浏览器
headers={'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36 Edg/114.0.1823.43'}
 
#发送请求
resp=requests.get(url,headers=headers)
print(resp.text)