import requests
import json
if __name__=='__main__':
# url是post请求的url
url='https://movie.douban.com/j/chart/top_list'
# UA伪装
headers={
'User-Agent': "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36"
}
# get请求的url
param={
"type": '5',
'interval_id': '100:90',
'action': '',
'start':' 0',
'limit':'20',
}
response=requests.get(url=url,headers=headers,params=param)
# 是否是json数据由content-type决定
list_data=response.json()
fp=open("./douban.json",'w',encoding='utf-8')
json.dump(list_data,fp=fp,ensure_ascii=False)
print(list_data)
爬取豆瓣电影排行
最新推荐文章于 2022-01-03 20:50:52 发布