#导入模快
from urllib import request, parse
#公共部分
url_base = 'https://movie.douban.com/j/chart/top_list?'
#循环输出
for i in range(5):
date = {
'type': '11',
'interval_id': '100:90',
'start': str(20 * i),
'limit': '20'
}
new_date = parse.urlencode(date)
url = url_base + new_date
content = request.urlopen(url).read().decode('utf-8')
#写入文件
with open('douban.txt', 'a', encoding='utf-8') as f:
f.write(content)
简单爬虫
最新推荐文章于 2023-04-03 11:18:10 发布