28 lines
902 B
Python
28 lines
902 B
Python
import requests
|
|
import re
|
|
|
|
url = 'https://www.douban.com/doulist/3936288/'
|
|
header = {'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36'}
|
|
response = requests.get(url, headers=header)
|
|
response.encoding = 'utf-8'
|
|
html = response.text
|
|
|
|
title_pattern = r'<div class="title">([^<]+)</a>'
|
|
titles = re.findall(title_pattern, html)
|
|
chinese_titles = [t for t in titles if not t.startswith('/')]
|
|
|
|
actor_pattern = r'主演:([^<]+)'
|
|
actors=re.findall(actor_pattern,html)
|
|
|
|
quote_pattern = r'<span class="inq">([^<]+)</span>'
|
|
quotes = re.findall(quote_pattern, html)
|
|
|
|
#limit=min(50,len(chinese_titles))
|
|
for i in range(min(50,len(chinese_titles))):
|
|
title = chinese_titles[i]
|
|
actor_pattern = actors[i]
|
|
quote = quotes[i]
|
|
print(f'"rank":{i+1},"title":{titles},"actor":{actors},"quotes": {quotes}')
|
|
|
|
|