diff --git a/ll.py b/ll.py new file mode 100644 index 0000000..8304e72 --- /dev/null +++ b/ll.py @@ -0,0 +1,27 @@ +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'
([^<]+)' +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'([^<]+)' +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}') + +