diff --git a/get_aoyun.py b/get_aoyun.py new file mode 100644 index 0000000..6d6a678 --- /dev/null +++ b/get_aoyun.py @@ -0,0 +1,21 @@ +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'>(.*?)",data) +list2 = re.findall('
(.*?)。',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') # 写入弹幕 \ No newline at end of file