import requests
import re
headers={
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.71 Safari/537.36 Core/1.94.197.400 QQBrowser/11.6.5265.400'
}
with open('./豆瓣前10.txt', 'w') as f:
for start_name in range(0,10):
start_name = start_name*25
url = f'https://movie.douban.com/top250?start={start_name}&filter='
html = requests.get(url,headers=headers).text
zc = re.compile('.*?(.*?)',re.S)
data = re.findall(zc,html)
for i in range(0, len(data)):
f.write(data[i]+'\n')
f.close()