From 5edf6994b7c42413730b188c9f360e522b74e44e Mon Sep 17 00:00:00 2001 From: p4ut7fwj5 <3346195219@qq.com> Date: Sun, 15 Sep 2024 18:47:07 +0800 Subject: [PATCH] Delete 'bv_maker.py' --- bv_maker.py | 38 -------------------------------------- 1 file changed, 38 deletions(-) delete mode 100644 bv_maker.py diff --git a/bv_maker.py b/bv_maker.py deleted file mode 100644 index 5e21dce..0000000 --- a/bv_maker.py +++ /dev/null @@ -1,38 +0,0 @@ -""" - 说明:爬取b站视频的bv号,为之后获取弹幕做好准备 -""" -import requests -import re #使用re解析 -BV_NUM = 300 # 定义需要的视频数量 -Search_Content = "2024巴黎奥运会" #定义搜索内容 -header = { -"user-agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36 Edg/128.0.0.0", -"referer":'https:"//search.bilibili.com/all?"' -} -def get_bv(num): - # 爬取300个BV号 - bv_list = set([]) - main_page_url_1 = f"https://search.bilibili.com/all?keyword={Search_Content}" - resp = requests.get(main_page_url_1, headers=header) - obj = re.compile(r'aid:.*?bvid:"(?P.*?)",') #获取视频的BVID用于获取弹幕 - # print(resp.text) - its = obj.finditer(resp.text) - for it in its: - bv_list.add(it.group("bvs")) - # print(bv_list) - - page = 2 - while (True): - main_page_url = f"https://search.bilibili.com/all?keyword={Search_Content}&page={page}" - resp = requests.get(main_page_url, headers=header) - # print(resp.text) - its = obj.finditer(resp.text) - for it in its: - bv_list.add(it.group("bvs")) - if len(bv_list) >= num: - return bv_list - page += 1 - -if __name__ == '__main__': - bv_list = get_bv(BV_NUM) - print(bv_list) \ No newline at end of file