爬虫入门__movie250

from bs4 import BeautifulSoup
import requests
def worm(url):
    r = requests.get(url)
    soup = BeautifulSoup(r.text,'lxml')
    lists = soup.find_all('div',class_ = 'info')
    for i in lists:
        movie_name = i.find('span',class_ = 'title')
        remark = i.find('span',class_ = 'inq')
        print('movie:' + movie_name.string)
        if remark:
            print('电影评语:' + remark.string,end = '\n\n')
        else:
            print('电影评语:' + 'None')
for j in range(0,275,25):
    if j>225:
        break
    url = 'https://movie.douban.com/top250?start={0}&filter='.format(j)
    worm(url)

你可能感兴趣的:(python)