爬取豆瓣电影Top250信息

时间:2022-09-18 18:37:51

 

# -*- coding:utf-8 -*-
__author__ = "MuT6 Sch01aR"

import requests
from pyquery import PyQuery

def GetDouBanMovie():
    a = 1
    for i in range(0,250,25):
        url = "https://movie.douban.com/top250?start=%s&filter=" %i
        r = requests.get(url)
        for movie in PyQuery(r.content)(".item"):
            num = PyQuery(movie).find(".rating_num").html()
            title = PyQuery(movie).find(".title").html()
            desc = PyQuery(movie).find(".inq").html()
            print("排名:%s 评分:%s 电影名字:%s 引述:%s" %(a,num,title,desc))
            a += 1
GetDouBanMovie()

 运行结果

爬取豆瓣电影Top250信息