requests 之豆瓣电影排行榜爬取

import json
import requests
if __name__ == '__main__':
    url = 'https://movie.douban.com/j/chart/top_list'
    param = {
        'type': '24',
        'interval_id': '100:90',
        'action':'',
        'start':'0', # 从库中的第几部电影中去取
        'limit': '20' # 一次取得个数
    }
    headers = {
        'User-Agent': 'Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36'
    }
    res = requests.get(url = url,params=param,headers=headers)
    list_data=res.json()
    fp = open('./douban.json','w',encoding='utf-8')
    json.dump(list_data,fp=fp,ensure_ascii=False)
    print("over!!!")

 

posted @ 2020-04-13 16:30  风hua  阅读(246)  评论(0编辑  收藏  举报