爬虫--豆瓣电影(励志分类区)

import requests
import time
from lxml import etree

for a in range(3):
    url = 'https://movie.douban.com/j/new_search_subjects?sort=T&range=0,10&tags=&start={}'.format(a*20)
    file = requests.get(url).json()
    time.sleep(3)
    
    for i in range(20):
        dict = file['data'][i]
        urlname = dict['url']
        title = dict['title']
        rate = dict['rate']
        cast = dict['casts']
        
        print('{} {} {} {}\n'.format(title,rate,' '.join(cast),urlname))
  • 输出情况如图(截取部分数据)


    加载部分图书信息

你可能感兴趣的:(爬虫--豆瓣电影(励志分类区))