diff --git a/获取弹幕地址.py b/获取弹幕地址.py new file mode 100644 index 0000000..012e9db --- /dev/null +++ b/获取弹幕地址.py @@ -0,0 +1,23 @@ +import requests +import re +#获取所需弹幕地址 +headers0={ + "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" +}#请求头 +for page0 in range(1,11):#从搜索的十页获取网址 + if page0==1 : + url="https://search.bilibili.com/all?vt=93020172&keyword=2024%E5%B7%B4%E9%BB%8E%E5%A5%A5%E8%BF%90%E4%BC%9A&from_source=webtop_search&spm_id_from=333.1007&search_source=5" + else: + url=f"https://search.bilibili.com/all?vt=93020172&keyword=2024%E5%B7%B4%E9%BB%8E%E5%A5%A5%E8%BF%90%E4%BC%9A&from_source=webtop_search&spm_id_from=333.1007&search_source=5&page={page0}" + res0=requests.get(url,headers=headers0)#获取网页数据 + Text0=res0.text + bvid=re.findall('bvid:"(.*?)",title:',Text0)#获取视频bvid号 + print(bvid) + for bvid1 in bvid:# + url=f"https://www.bilibili.com/video/{bvid1.strip()}/?spm_id_from=333.337.search-card.all.click&vd_source=516714ff716c382225c801afa2c87d8d" + res0=requests.get(url,headers=headers0)#获取视频数据 + Text0=res0.text + oid=re.findall('"embedPlayer":{"p":.*?,"aid":.*?,"bvid":".*?","cid":(.*?),',Text0)#获取oid值(多余空格去除,不然匹配不到) + + +