Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import re,urllib.request
- def wiki(url):
- web_page = urllib.request.urlopen(url)
- lines = web_page.read().decode(errors="replace")
- web_page.close()
- body_link = re.findall('(?<=<table class="wikitable sortable).+?(?=</table>)',lines,re.DOTALL)
- movies = re.findall('(?<=<i><a href=").+?(?=")',body_link[0],re.DOTALL)
- ui = input('Please select a top 10 movie: ')
- for item in movies:
- if ui in item:
- the_movie = urllib.request.urlopen('https://en.wikipedia.org'+item)
- content = the_movie.read().decode(errors="replace")
- findit = re.findall('(?<=span class="mw-headline" id="Plot").+?\
- (?=<h2>)',content,re.DOTALL)
- print(findit)
- wiki('https://en.wikipedia.org/wiki/2017_in_film')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement