From 3a5a6d4c415cc87fcac95c8833f342373d5de743 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E9=92=A6=E7=87=95?= <2509165038@student.example.com> Date: Tue, 31 Mar 2026 11:26:23 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E6=96=87=E4=BB=B6=E8=87=B3?= =?UTF-8?q?=20/?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 陈钦燕.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 陈钦燕.py diff --git a/陈钦燕.py b/陈钦燕.py new file mode 100644 index 0000000..1404b1f --- /dev/null +++ b/陈钦燕.py @@ -0,0 +1,22 @@ +import requests +import re + +headers ={ + 'User-Agent': "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chroe/120.0.0.0 Safari/537.36", +} +url = 'https://movie.douban.com/top250' + + + +response = requests.get(url,header=headers) +html = response.text + +pattern = r' = "title">([^<&]+)' +titles = pattern.findall(html , pattern) +chinese_titles = [t for t in titles if not t.startswith('/')] +top10_titles = chinese_titles[:10] +with open ("movies.txt","w",encoding="utf-8") as f: + for idx,titles in enumerate(top10_titles,1): + f.write(f"{idx}. {title}\n") +print("前十部电脑名称已保存到movies.txt") +