From 3def331f72f4868c93a323ca4f80ac3d191370f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E9=92=A6=E7=87=95?= <2509165038@student.example.com> Date: Tue, 24 Mar 2026 11:32:21 +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 --- 260324 2509165038.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 260324 2509165038.py diff --git a/260324 2509165038.py b/260324 2509165038.py new file mode 100644 index 0000000..383f403 --- /dev/null +++ b/260324 2509165038.py @@ -0,0 +1,24 @@ +import requests +from bs4 import BeautifulSoup + +headers ={ + 'User-Agent': "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chroe/120.0.0.0 Safari/537.36", +} +for page in range(10): + + url = f"https://movie.douban.com/top250?start={page*25}&filter=" + print(f"正在爬取第{page + 1} 页 : {url}") + +response = requests.get(url,header=headers,timeout=10) +response.encoding = 'utf-8' + +soup BeautifulSoup(response.txt, 'html.parser') +movie = [] +for a in soup.find_all('a'): + href = a.get('herf','') + if'/subject' in herf: + title = a.get_text(strip = Ture) + print(title) + movie.appent(title) +print('------------') +print(movie) \ No newline at end of file