requests 模块允许您使用 Python 发送 HTTP 请求。
HTTP 请求返回 Response 对象,其中包含所有响应数据(内容、编码、状态等)。
| 方法 | 描述 |
|---|---|
| delete(url, args) | 向指定的 URL 发送 DELETE 请求。 |
| get(url, params, args) | 向指定的 URL 发送 GET 请求。 |
| head(url, args) | 向指定的 URL 发送 HEAD 请求。 |
| patch(url, data, args) | 向指定的 URL 发送 PATCH 请求。 |
| post(url, data, json, args) | 向指定的 URL 发送 POST 请求。 |
| put(url, data, args) | 向指定的 URL 发送 PUT 请求。 |
| request(method, url, args) | 将指定方法的请求发送到指定的 URL。 |
向网页发出请求,并打印响应文本:
import requests
x = requests.get('https://w3school.com.cn/python/demopage.htm')
print(x.text)
运行实例
将命令行导航到 PIP 的位置,然后键入以下内容:
C:\Users\Your Name\AppData\Local\Programs\Python\Python36-32\Scripts>pip install requests
requests.methodname(params)
相关
视频
RELATED VIDEOS
科技资讯
1
2
3
4
5
6
7
8
9
精选课程
共5课时
17.2万人学习
共49课时
77.2万人学习
共29课时
61.8万人学习
共25课时
39.4万人学习
共43课时
71.1万人学习
共25课时
61.7万人学习
共22课时
23万人学习
共28课时
34万人学习
共89课时
125.4万人学习