豆瓣,get请求查看ajax,下拉滚轮刷新新板块的数据
可查看的,调用的参数。写入代码的kv对中
代码为
import requests
import json
# 滚轮拖动刷新更多数据
url='https://movie.douban.com/j/chart/top_list'
#参数都做成字典,kv对
params={'type':'24','interval_id':'100:90','action':'','start':'0',#从第几部电影去取'limit':'20'#每次取出的个数,可更改为200
}
headers={
'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.84 Safari/537.36'
}
response=requests.get(url=url,params=params,headers=headers)
list_data=response.json()
fp=open('./douban.json','w',encoding='utf-8')
json.dump(list_data,fp=fp,ensure_ascii=False)