
利用Python的requests库进行网页抓取及自定义头部信息传送
5星
- 浏览量: 0
- 大小:None
- 文件类型:None
简介:
本教程介绍如何使用Python的requests库来实现网页抓取,并讲解了在请求中添加自定义头部信息的方法。适合初学者快速上手网络数据采集。
首先引入requests模块:
```python
import requests
```
一、发送请求
使用`requests.get()`方法进行GET请求:
```python
r = requests.get(https://api.github.com/events)
```
使用`requests.post()`方法进行POST请求:
```python
r = requests.post(http://httpbin.org/post, data={key:value})
```
使用`requests.put()`方法进行PUT请求:
```python
r = requests.put(http://httpbin.org/put, data={key:value})
```
使用`requests.delete()`方法进行DELETE请求:
```python
r = requests.delete(http://httpbin.org/delete)
```
全部评论 (0)
还没有任何评论哟~


