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.
21 lines
726 B
21 lines
726 B
import requests
|
|
import re
|
|
|
|
header = {"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"}
|
|
|
|
url = "http://sports.news.cn/olympicparis2024/index.html"
|
|
response = requests.get(url=url, headers=header)
|
|
response.encoding = 'utf-8'
|
|
data = response.text
|
|
|
|
list1 = re.findall("blank'>(.*?)</a>",data)
|
|
list2 = re.findall('</a></div> <div data-swiper-parallax="-500" class="abs">(.*?)。',data)
|
|
content = []
|
|
|
|
content.extend(list1)
|
|
content.extend(list2)
|
|
print(content)
|
|
|
|
for i in content: # 遍历弹幕
|
|
with open('aoyun.txt', 'a', encoding='utf-8') as f: # 打开文件准备写入
|
|
f.write(i + '\n') # 写入弹幕 |