From 7071250053799a8138a5ab0bc7eb398c9e7bec84 Mon Sep 17 00:00:00 2001 From: p4oufk2iw <2488672761@qq.com> Date: Wed, 18 Sep 2024 03:41:21 +0800 Subject: [PATCH] ADD file via upload --- get_danmu.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 get_danmu.py diff --git a/get_danmu.py b/get_danmu.py new file mode 100644 index 0000000..294bdc0 --- /dev/null +++ b/get_danmu.py @@ -0,0 +1,26 @@ +# 获取弹幕地址 + + +def get_danmu_url(video_str): + url = video_str + response = requests.get(url=url, headers=headers) + html = response.text + cid = re.search('"cid":(.*?),', html).groups()[0] + danmu_url = f'https://comment.bilibili.com/{cid}.xml' + return danmu_url + +# 获取视频地址 + + +def get_vedio(bv): + vedio_url = "https://www.bilibili.com/video/"+bv + return vedio_url +# 获取bv号 + + +def get_bvid(url, pos): + + # 通过搜索api“https://api.bilibili.com/x/web-interface/search/all/v2?page=1-15&keyword=”获取前300个视频的bvid + res = requests.get(url=url, headers=headers).text + json_dict = json.loads(res) + return json_dict["data"]["result"][11]["data"][pos]["bvid"]