Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. import re,urllib.request
  2.  
  3. def wiki(url):
  4. web_page = urllib.request.urlopen(url)
  5. lines = web_page.read().decode(errors="replace")
  6. web_page.close()
  7. body_link = re.findall('(?<=<table class="wikitable sortable).+?(?=</table>)',lines,re.DOTALL)
  8.  
  9. movies = re.findall('(?<=<i><a href=").+?(?=")',body_link[0],re.DOTALL)
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16. ui = input('Please select a top 10 movie: ')
  17.  
  18. for item in movies:
  19. if ui in item:
  20.  
  21.  
  22. the_movie = urllib.request.urlopen('https://en.wikipedia.org'+item)
  23. content = the_movie.read().decode(errors="replace")
  24.  
  25.  
  26. findit = re.findall('(?<=span class="mw-headline" id="Plot").+?\
  27. (?=<h2>)',content,re.DOTALL)
  28.  
  29. print(findit)
  30.  
  31.  
  32. wiki('https://en.wikipedia.org/wiki/2017_in_film')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement