# -*- coding:utf8 -*-
# -*- author:xiaoxiang -*-
import requests
from bs4 import BeautifulSoup
def get_cid(the_url):
url = the_url
response = requests.get(url)
cid = response.content.decode().split("cid=")[1].split("&aid=")[0]
return cid
def get_html():
url = f"https://www.bilibili.com/video/BV1vp4y1a7Ea?p={1}"
response = get_cid(url)
the_xml = requests.get(f"https://comment.bilibili.com/{response}.xml")
soup = BeautifulSoup(the_xml.content, "html.parser")
all_danmu = soup.find_all("d")
for i in all_danmu:
print(i.next_element)
if __name__ == '__main__':
# print("请输入BV")
# BV = input()
# print("请输入p数")
# end = input()
get_html()
python获取b站某视频弹幕
最新推荐文章于 2024-04-26 01:45:18 发布