美文网首页
python简单处理http请求

python简单处理http请求

作者: 金玖壹拾 | 来源:发表于2023-01-13 22:37 被阅读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化文档。

相关文章

网友评论

      本文标题:python简单处理http请求

      本文链接:https://www.haomeiwen.com/subject/gwlncdtx.html