You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
17 lines
482 B
17 lines
482 B
2 months ago
|
import requests
|
||
|
import xml.etree.ElementTree as ET
|
||
|
|
||
|
|
||
|
def get_danmaku(video_id):
|
||
|
url = "https://api.bilibili.com/x/v1/dm/list.so?oid={}".format(video_id)
|
||
|
response = requests.get(url)
|
||
|
if response.status_code == 200:
|
||
|
root = ET.fromstring(response.content)
|
||
|
danmaku_list = []
|
||
|
for d in root.findall('d'):
|
||
|
text = d.text
|
||
|
if text:
|
||
|
danmaku_list.append(text)
|
||
|
return danmaku_list
|
||
|
return []
|