From 94b1997f9f0b6fbbc2605081c5c47076ee63a2b6 Mon Sep 17 00:00:00 2001
From: 2509165008 <2509165008@student.edu.cn>
Date: Thu, 2 Apr 2026 16:06:25 +0800
Subject: [PATCH] work
---
work/tll.py | 37 +++++++++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+)
create mode 100644 work/tll.py
diff --git a/work/tll.py b/work/tll.py
new file mode 100644
index 0000000..9f7e6d4
--- /dev/null
+++ b/work/tll.py
@@ -0,0 +1,37 @@
+# 准备:导入必要的库
+import requests
+import re
+import csv
+import json
+import time
+
+# 设置请求头,模拟浏览器访问
+headers = {
+ 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36'
+}
+
+url = 'https://movie.douban.com/top250'
+
+print('开始爬取豆瓣电影Top250...')
+response = requests.get(url, headers=headers)
+print(f'状态码: {response.status_code}')
+print(f'内容长度: {len(response.text)} 字符')
+
+# 找到所有电影标题
+html = response.text
+
+# 匹配 电影名
+title_pattern = r'([^<]+)'
+titles = re.findall(title_pattern, html)
+
+# 过滤掉英文名(以/开头)
+chinese_titles = [t for t in titles if not t.startswith('/')]
+
+print('电影名称(前10部):')
+for i, title in enumerate(chinese_titles[:10], 1):
+ print(f'{i}. {title}')
+
+
+
+pingjia = r'[0-9]([^<]+)'
+pingjias = re.findall(pingjia,html)
\ No newline at end of file