From 7b9a16f77d92a3982f10b55f7f4bfbb7ca7d4a7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=96=B9=E6=96=87=E6=9D=B0?= <2509165027@student.example.com> Date: Tue, 31 Mar 2026 11:37:29 +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 --- 5.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 5.py diff --git a/5.py b/5.py new file mode 100644 index 0000000..e44bcf5 --- /dev/null +++ b/5.py @@ -0,0 +1,17 @@ +import requests +import re +import csv +import json + +header={ + 'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36' + } + +url='https://www.douban.com/doulist/3936288/' +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)