24 lines
572 B
Plaintext
24 lines
572 B
Plaintext
import requests
|
|
from bs4 import BeautifulSoup
|
|
|
|
headers = {
|
|
'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://movie.douban.com/top250?start=25&filter='
|
|
|
|
response = requests.get(url,headers=headers,timeout=10)
|
|
response.encoding = 'utf-8'
|
|
|
|
# print(response.status-code)
|
|
|
|
soup = BeautifulSoup(response.text,'html.parser')
|
|
|
|
movies = []
|
|
|
|
for item in soup.find_all('div',class_='hd'):
|
|
a = item.find('a')
|
|
if a:
|
|
print(a.get_text(strip=True))
|
|
|