python简单处理http请求
2023-01-13 本文已影响0人
金玖壹拾
代码块
response = requests.get(url=url, headers=headers, params=params)
html = etree.HTML(response.text)
python request库
requests.get()意为获取网页,对应HTTP中GET方法。
response是一个Response对象,包含了服务器资源。
参数
url:requests发起请求的地址
headers:请求头
params:字符参数
python lxml库 etree库
etree.HTML()用于HTML化文档。