Advertisement
Guest User

Untitled

a guest
May 27th, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.71 KB | None | 0 0
  1. from bs4 import BeautifulSoup
  2. import requests
  3.  
  4. page_link = "https://www.imdb.com/search/title?groups=top_250&sort=user_rating,desc"
  5.  
  6. # response
  7. page_response = requests.get(page_link, timeout=5)
  8.  
  9. #here we have page content -> check structure of webpage
  10. page_content = BeautifulSoup(page_response.content, "html.parser")
  11.  
  12. movie_containers = page_content.find_all('div', class_ = 'lister-item mode-advanced')
  13.  
  14. for movie in movie_containers:
  15.     #name
  16.     print("Name: "+movie.a.img['alt'])
  17.     print("\tYear: "+movie.find("span", {"class": "lister-item-year text-muted unbold"}).text[1:-1])
  18.     print("\tRating: "+movie.find("div", {"class": "inline-block ratings-imdb-rating"})["data-value"])
  19.     print()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement