import requests
import json
if __name__ == "__main__":
url = 'https://movie.douban.com/j/chart/top_list' #url?后边的参数用字典封装
headers = {
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36'
}
param = {
'type': '24',
'interval_id': '100:90',
'action':'',
'start': '0',#从库中的第几部电影去取(索引)
'limit': '20',#一次取出的个数
}
response = requests.get(url=url,params=param,headers=headers)
list_data = response.json()
fp = open('./douban.json','w',encoding='utf-8')
json.dump(list_data,fp=fp,ensure_ascii=False)
print('over!!!')
requests实战之豆瓣电影爬取(路飞学城
于 2023-10-12 09:22:57 首次发布