「Python」- HTTP(s)

内容简介

整理发送HTTP(s)请求的库(只因urlib难以记忆)。

Requests: HTTP for Humans

https://requests.readthedocs.io/en/master/

https://github.com/psf/requests/
12/25/2019 Star 41.1k

使用基础认证

requests.get('https://example.com/user', auth=('username', "password"))

在请求中提交 XML 数据

requests.get(
	'https://example.com',
	headers={'Content-Type': 'application/xml; charset: utf-8'},
	data="<xml_string>"
)

urllib3

https://urllib3.readthedocs.io/en/latest/

https://github.com/urllib3/urllib3
12/25/2019 Star 2.2k

参考文献

Python’s Requests Library (Guide)
How can I send an xml body using requests library?