From b34e7d286340a1c4226cbf2fbb64217c156f26ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E6=83=A0=E7=87=95?= <2509165043@student.example.com> Date: Thu, 2 Apr 2026 16:04:52 +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 --- 26.04.02 43.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 26.04.02 43.py diff --git a/26.04.02 43.py b/26.04.02 43.py new file mode 100644 index 0000000..ab5c41e --- /dev/null +++ b/26.04.02 43.py @@ -0,0 +1,26 @@ +import requests +import re + +url = 'https://www.douban.com/doulist/3936288/' +headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36'} +response = requests.get(url, headers=headers) +response.encoding = response.apparent_encoding +html = response.text + +title_pattern = r'([^<]+)' +titles = re.findall(title_pattern, html) +chinese_titles = [t.strip() for t in titles if not t.startswith('/')] + +rating_pattern = r']*>(\d+\.\d)' +ratings = re.findall(rating_pattern, html) + +quote_pattern = r'([^<]+)' +quotes = re.findall(quote_pattern, html) + +print(f"{'排名':<4} {'电影名':<20} {'评分':<6} {'引言'}") +print('-' * 40) +for i in range(min(10, len(chinese_titles))): + title = chinese_titles[i] if i