Skip to content

Commit 8b52e44

Browse files
orkunincilicclauss
authored andcommitted
Python program that listing top 'n' movie in imdb (#1477)
* Python program that listing top 'n' movie in imdb * Update get_imdbtop.py
1 parent a7078d7 commit 8b52e44

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

web_programming/get_imdbtop.py

+18
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)