We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent a7078d7 commit 8b52e44Copy full SHA for 8b52e44
web_programming/get_imdbtop.py
@@ -0,0 +1,18 @@
1
+from bs4 import BeautifulSoup
2
+import requests
3
+
4
5
+def imdb_top(imdb_top_n):
6
+ base_url = (f"https://www.imdb.com/search/title?title_type="
7
+ f"feature&sort=num_votes,desc&count={imdb_top_n}")
8
+ source = BeautifulSoup(requests.get(base_url).content, "html.parser")
9
+ for m in source.findAll("div", class_="lister-item mode-advanced"):
10
+ print("\n" + m.h3.a.text) # movie's name
11
+ print(m.find("span", attrs={"class": "genre"}).text) # genre
12
+ print(m.strong.text) # movie's rating
13
+ print(f"https://www.imdb.com{m.a.get('href')}") # movie's page link
14
+ print("*" * 40)
15
16
17
+if __name__ == "__main__":
18
+ imdb_top(input("How many movies would you like to see? "))
0 commit comments