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爬取电影代码
最新推荐文章于 2024-08-22 17:32:24 发布