Grab the Douban movie (http://movie.douban.com/nowplaying/chengdu/) In front of the movie 12 movie , They are ranked according to their scores , Save to txt file
from selenium import webdriver
from time import sleep class DoubanMovie(unittest.TestCase): def setUp(self):
self.dr = webdriver.Chrome()
self.top_movie_list = self.get_douban_movies_top12()
self.movie = self.get_movie_top12_file() def get_douban_movies_top12(self):
''' Before getting Douban movie being released in Chengdu area 12 The name and rating of the movie '''
movie_list = # Define empty list Prepare for storing movie names and movie ratings in the back
i = 0
while i < 60: #12*5=60
movie_name = self.dr.find_elements_by_css_selector('.lists li')[i].get_attribute('data-title')# Locate the name of the movie
movie_grand = self.dr.find_elements_by_css_selector('.lists li')[i].get_attribute('data-score')# Positioning movie ratings
movie_list.append([movie_name,movie_grand])# To the sky list Add the movie name and movie score
i += 5 # Every movie's li The label interval is 5 individual
movie_list.sort(key=lambda x:x, reverse=True)# utilize sort in key According to Movie ratings Sort the movies from high to low (movie_list = sorted(movie_list, key=lambda movie: movic, reverse=True) # sort by movie_grand In reverse order )
return movie_list def get_movie_top12_file(self):
self.file_title = ' Before the Douban film is being shown in Chengdu 12 movie '
self.file = open(self.file_title + '.txt', 'wb')
for item in self.top_movie_list:
self.file.write((' The name of the movie :' + item + ' ' + ' Movie ratings :' + item + '\n').encode('utf-8'))
self.file.close() def test_movie(self):
print(" Acquisition complete ") def tearDown(self):
self.dr.quit() if __name__ == '__main__':
notes ： There is no rating in the movie for the time being 0 branch .
use python+selenium Grab the one in the Douban movie before the hit 12 More related articles about movies and ranking by ratings
- use python+selenium Grab the most concerned books in Douban reading and rank them according to the score
Grab Douban in reading (http://book.douban.com/) The most popular books , Sort by score , And save to txt In file , Need to grab the name of the book , author , score , Genre and one sentence review Method 1 : #coding=utf-8 ...
- Python Reptiles ---- Grab the Douban movie Top250
With the last use python The experience of crawling through the Encyclopedia of scandals , This time, I wrote a movie about crawler catching Douban Top250 Brief information of . 1. Observe url First, look at the structure of the web address http://movie.douban.com/to ...
- Nezha's box office is super complex 4,100 That's ok python Code grab Douban short review , Let's see what netizens say
< The devil child of Nezha came into the world > This is the pinnacle of domestic animation , It's about a month since its release , Box office word-of-mouth double harvest . So far, more than 100 million people have watched , Box office to achieve 42.39 One hundred million yuan , More than double 4, Third place in China's box office record , Second only to < Warwolf 2> ...
- use python+selenium Capture microblog 24 Before the hot topic of the hour 15 And save it to txt in
Capture microblog 24 Before the hot topic of the hour 15 individual , Please save the captured content to txt In file , Need to grab the rankings . Topics and readings #coding=utf-8 from selenium import webdriver import ...
- python Crawler grabs Douban movie
Grab the movie title and score , And sort ( The code is ugly ) import urllib import re from bs4 import BeautifulSoup def get(p): t=0 k=1 n=1 b ...
- use python+selenium Capture today's hottest and this month's hottest top three questions and the first answer to each question and save them to html file
Grab the top three questions of today and this month and the first answer to each question , Save to html file , The html The file name of the file should be 20160228_zhihu_today_hot.html, That's the date +zhihu_toda ...
- Python Grab the Douban movie top250!
Preface The text and pictures of this article come from the Internet , Just for learning . Communication use , Not for any commercial purpose , The copyright belongs to the original author , If you have any questions, please contact us in time for handling . author :404notfound Always interested in reptiles , To learn the python I just saw ...
- Python：python Grab the Douban movie top250
Always interested in reptiles , To learn the python Later, I saw some article about crawling , Let's fight it out of the blue . Achieve the goal : Grab the Douban movie top250, And output it to a file 1. Find the corresponding url:https://movie.douba ...
- Python Little reptile —— Grab the Douban movie Top250 data
python Grab the Douban movie Top250 data 1. Douban address :https://movie.douban.com/top250?start=25&filter= 2. The main process is to capture the Top25 ...
- vs2015 Manual installation xamarin
1. install jdk Download the Java JDK v1.7.0 installer to any directory on your disk, double-click the downl ...
- Distributed algorithm one —— Uniformity hash Algorithm
Excerpt from :http://blog.csdn.net/sparkliang/article/details/5279393
- PAT 1020
1020. Tree Traversals (25) Suppose that all the keys in a binary tree are distinct positive integers ...
- jsp fmt Label details
See :http://blog.yemou.net/article/query/info/tytfjhfascvhzxcyt326 JSTL The label provides an insight into internationalization (I18N) Support for , It can be based on the customer making the request ...
- python Learning notes ——Day 1
python What language is it ? Compilation and interpretation Compiler is to compile every statement of source program into machine language , And save as binary file , In this way, the runtime computer can run the program directly in machine language , fast ; The interpreter only executes the program , Just one ...
Deep Laplacian Pyramid Networks for Fast and Accurate Super-Resolution solve the problem : 1.bicubic Preprocessing up and down sampling , High computational complexity ...
- Zero basis Python Reptile implementation ( Baidu post bar )
Tips : This study comes from Ehco The article of the elder generation , Notes from implementation . The goal is http://tieba.baidu.com/f?kw=linux&ie=utf-8 Website structure Learning goals Because it's the first experimental property ...
- El The static method is called
Recently, I encountered the problem of calling static methods in my project , Form like : <c:forEach items="beans" var="bean"> <p> total :$ ...
- oracle Terms in
database : A database is a real file , A database file system generally contains ( Data files DBF. Control documents CTL. Log files LOG) Database instance : Each database has a database instance corresponding to it , The external environment should interact with the database instance ...
- js One of the three families offset
JS Medium offset family : One .offsetWidth And offsetHeight: Get the actual width and height of the element = width + border + padding Be careful : 1. You can get the width and height of the line and embedded ...