parent
23e88f32eb
commit
3962b6a034
@ -0,0 +1,17 @@
|
|||||||
|
import requests
|
||||||
|
import re
|
||||||
|
url='https://api.bilibili.com/x/v1/dm/list.so?oid=25761744510'
|
||||||
|
Hddf = {
|
||||||
|
"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"
|
||||||
|
}
|
||||||
|
resp= requests.get(url,headers=Hddf)#从网址获取弹幕
|
||||||
|
resp.encoding="utf-8"#弹幕中文编码
|
||||||
|
Data=resp.text#提取text文本
|
||||||
|
context=re.findall('<d p=.*?>(.*?)</d>',Data)#提取弹幕文本
|
||||||
|
print(context)
|
||||||
|
for index in context:
|
||||||
|
with open('a.txt',mode='a',encoding='utf-8')as f:
|
||||||
|
f.write(index)#写入text文件
|
||||||
|
f.write('\n')
|
||||||
|
|
||||||
|
|
Loading…
Reference in new issue