上传文件至 /
This commit is contained in:
24
260324 2509165038.py
Normal file
24
260324 2509165038.py
Normal file
@@ -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)
|
||||||
Reference in New Issue
Block a user