From 2ac53b0b7f8d23ad0e99ed7ce1b37be36df86058 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E7=BA=A2=E8=BE=89?= <2509165036@student.example.com> Date: Tue, 31 Mar 2026 11:23:01 +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 --- text.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 text.py diff --git a/text.py b/text.py new file mode 100644 index 0000000..33f2e69 --- /dev/null +++ b/text.py @@ -0,0 +1,14 @@ +import requests +import re +url = "https://movie.douban.com/top250" +headers = { + "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36" +} +response = requests.get(url, headers=headers) +html = response.text +pattern = re.compile(r'(.*?)', re.S) +movie_names = pattern.findall(html) +chinese_names = [name for name in movie_names if not name.startswith('/')] +print('电影名称(前10部):') +for i, title in enumerate(chinese_titles[:10], 1): + print(f'{i}. {title}') \ No newline at end of file