用python爬取电影代码

import requestsfrom bs4 import BeautifulSoupurl = 'https://movie.douban.com/chart'wb_data = requests.get(url)soup = BeautifulSoup(wb_data.text,'lxml')movies = soup.select('#content > div > div.article > div:nth-of-type(1) > table > tbody > tr')for movie in movies: title = movie.find("span").get_text() star = movie.find("span",{"class":"rating_nums"}).get_text() url = movie.get("a")["href"] data = movie.find("div",{"class":"star"}).find_all("span")[3].get_text() print("片名:%s\t评分:%s\t网址:%s\t评分人数:%s\n"%(title,star,url,data))

你可能感兴趣的:(python)