Grab the movie name and score, and sort (code ugly fried)
1 ImportUrllib2 ImportRe3 fromBs4ImportBeautifulSoup4 defget (P):5t=06K=17N=18Book_score=[]9Book_a=[]Ten whilet<=P: One Print "getting page%d ..."%k AK=k+1 -Url="Https://movie.douban.com/tag/%s?start=%d&type=T"%('%E5%8A%A8%E7%94%BB', T) -res =urllib.urlopen (URL) theSoup = BeautifulSoup (Res.read (),"Html.parser") -Book_div = Soup.find (attrs={"class":"article"}) -Book_score.extend (Book_div.findall (attrs={'class':'rating_nums'})) -Book_a.extend (Book_div.findall (attrs={"style":"font-size:12px;"})) +T=t+20 - returnbook_score,book_a + AP=input ("Enter number of pages") atA,b=get ((p-1) *20) -t=0 -y=[] -x=[] - forIinchA: - Y.append ((i.string)) in forIinchB: - x.append (i) tou=min (len (x), Len (y)) + forIinchRange (U): - forJinchRange (i+1, u): the if(y[i]<Y[j]): *t=Y[j] $y[j]=Y[i]Panax Notoginsengy[i]=T -t=X[j] thex[j]=X[i] +x[i]=T A the forIinchRange (U): + PrintY[i],x[i].string
Crawl results:
Enter page 2
getting 1th page ...
getting 2nd page ...
9.3 Watts (Taiwan)/Space Raider E (HK)
9.2 hidden Maiden (set)/Spirited Away
9.2 Metropolitan (Hong Kong)/animal-side City (Taiwan)
9.0 tenkûno Shiro Rapyuta/laputa:castle in the Sky
8.9 Soaring (HK)/extraterrestrial Miracle (Taiwan)
8.8 Lion King 3D
8.8 Guru Family (HK/Taiwan)/Crude
8.8 Firefly's Club/Hotarubi no Mori e
8.8 The Moving Castle of the Roaring Mountain/Hall
8.8 Ocean Fantasia (set)/Le Chant de la Mer
8.8 Tiecheng's Cabaneri/a Tiecheng corpse man
8.8 Magic Princess/Ghost Girl
8.7 Destruction Wanglalf/destruction Wanda Adventure
8.7 borrowed Girl Alitio (Taiwan)/Borrowed dwarf Ariati (HK)
8.7 Dragon Trainer (HK)
8.7 Friends (HK)/Brain Teasers (Taiwan)
8.6 Monster Company (HK)/monster company
8.6 League of Great Heroes (Hong Kong)/Great Heroes Day Group (Taiwan)
8.5 Despicable Me/Villain Award janitor (HK)
8.5 Second speed five cm/second speed 5 cm
8.5 My name is Sakamoto, and I'm the most cock .
8.4 Little Lamb Sean big movie/Super Invincible Goat BAA Big Movie (HK)
8.4 Moon Keeper
8.4 Ice Age/Ice Original Adventures
8.3 Magic Snow (Harbor)/Ice Adventure
8.3 Homecoming/Monkey King
8.2 Undersea Raiders/looking for Nemo
8.1 Despicable Me 2/Villain Award Janitor 2 (HK)
8.1 The Little Prince
8.0 Monsters Power Company 2: Monsters University/Monsters Inc. 2: Monsters University
8.0 Panda po 2/Bao 2
7.9 Dance with the forest (Taiwan)/Book of the Jungle
7.9 panda bao/Bao
7.8 panda Bao 3/Bao 3
7.7 Monster Kids (set)/Bakemono no Ko
7.5 Scream Hostel 2 (SET)/The Grinch Hotel 2 (Hong Kong)
7.3 Small Yellow/Mini Corps (HK)
7.2 Angry Birds Big Movie (HK)/Angry Birds play Movie (Taiwan)
7.1 Dinosaur era (port)/beautiful dinosaur World
Python crawler captures watercress movies