编写python爬虫代码获取b站视频
时间: 2024-03-02 15:20:54 浏览: 173
好的,以下是获取b站视频的Python爬虫代码:
```python
import requests
import json
# 获取视频信息的API地址
url = "https://api.bilibili.com/x/web-interface/view?bvid="
# 视频的BV号
bvid = "BV1Jx411d7dA"
# 发送请求
response = requests.get(url + bvid)
# 解析返回的JSON数据
data = json.loads(response.text)
# 打印视频标题和链接
print("视频标题:", data["data"]["title"])
print("视频链接:", data["data"]["pages"][0]["url"])
```
运行以上代码,即可获取指定BV号的B站视频标题和链接。当然,你可以根据自己的需求进行修改。
阅读全文
相关推荐


















