From cef800159ea85db59e41e310c9aac822dbfe326c Mon Sep 17 00:00:00 2001
From: 2509165019 <2509165019@student.edu.cn>
Date: Thu, 2 Apr 2026 15:53:06 +0800
Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E4=BD=9C=E4=B8=9AX?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
爬虫.py | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
create mode 100644 爬虫.py
diff --git a/爬虫.py b/爬虫.py
new file mode 100644
index 0000000..b9674c9
--- /dev/null
+++ b/爬虫.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 = 'utf-8'
+html = response.text
+
+title_pattern = r'([^<]+)'
+titles = re.findall(title_pattern, html)
+chinese_titles = [t 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('-' * 70)
+for i in range(min(10, len(chinese_titles))):
+ title = chinese_titles[i]
+ rating = ratings[i] if i < len(ratings) else '无'
+ quote = f'"{quotes[i]}"' if i < len(quotes) else '无'
+ print(f'{i+1:<4} {title:<20} {rating:<6} {quote}')
\ No newline at end of file