import requests
import re
import time
from concurrent.futures import ThreadPoolExecutor as Th
t1 = int(time.time())
url = input("输入网址:")
Bv = re.findall(r'/(BV.*?)\?', url)
if Bv == []:
Bv = re.findall(r"/(BV.*?)/", url)[0]
else:
Bv = Bv[0]
print(Bv)
f = open(f"b站评论/{Bv}.txt", "w", encoding="utf-8")
headers = {
"user-agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36", 'referer': url}
def get_av(url):
resp = requests.get(url=url, headers=headers).content.decode()
av = re.findall('{"aid":(\d*?),"bvid":".*?",', resp, re.S)[0]
return av
#额
def get_comment(oid):
try:
for o in range(1, 21):
urls = f"https://api.bilibili.com/x/v2/reply/main?jsonp=jsonp&next=
Python爬取b站视频的评论
最新推荐文章于 2025-04-04 23:25:33 发布