Skip to content

Commit 425dd48

Browse files
committed
Implementing open movie database API
1 parent 63176e2 commit 425dd48

4 files changed

Lines changed: 36 additions & 24 deletions

File tree

.DS_Store

8 KB
Binary file not shown.

projects/.DS_Store

14 KB
Binary file not shown.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"python.pythonPath": "/Users/utkarsh/Desktop/open_source/oscenv/bin/python3"
3+
}

projects/Find_imdb_rating/find_IMDb_rating.py

Lines changed: 33 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,37 @@
22
from bs4 import BeautifulSoup
33

44
# Defining variables and url
5-
title = str(input("Enter the title of movie/series: ")).lower()
6-
release = str(input("Enter the year of release: ")).lower()
5+
title = str(input("Enter the title of movie/series: "))
6+
release = str(input("Enter the year of release: "))
77
query = "+".join(title.split())
8-
URL = f"https://www.imdb.com/search/title/?title={query}"
9-
10-
s = requests.session() # Setting up session
11-
12-
try:
13-
response = s.get(URL)
14-
soup = BeautifulSoup(response.content, features="lxml")
15-
containers = soup.find_all("div", class_="lister-item-content")
16-
17-
for result in containers:
18-
name = result.h3.a.text.lower()
19-
year = result.h3.find(
20-
"span", class_="lister-item-year text-muted unbold"
21-
).text.lower()
22-
23-
if title in name and release in year:
24-
rating = result.find("div",
25-
class_="inline-block ratings-imdb-rating")[
26-
"data-value"]
27-
print(f"Rating of {name}:", rating)
28-
except Exception:
29-
print("Try again with valid combination of tile and release year")
8+
#RL = f"https://www.imdb.com/search/title/?title={query}"
9+
10+
request_link = 'http://www.omdbapi.com/?i=tt3896198&apikey=2c84f11f'
11+
12+
#api_key = 2c84f11f
13+
14+
request = request_link + '&t=' + query
15+
result = requests.get(request)
16+
17+
print(result.text)
18+
19+
# s = requests.session() # Setting up session
20+
21+
# try:
22+
# response = s.get(URL)
23+
# soup = BeautifulSoup(response.content, features="lxml")
24+
# containers = soup.find_all("div", class_="lister-item-content")
25+
26+
# for result in containers:
27+
# name = result.h3.a.text.lower()
28+
# year = result.h3.find(
29+
# "span", class_="lister-item-year text-muted unbold"
30+
# ).text.lower()
31+
32+
# if title in name and release in year:
33+
# rating = result.find("div",
34+
# class_="inline-block ratings-imdb-rating")[
35+
# "data-value"]
36+
# print(f"Rating of {name}:", rating)
37+
# except Exception:
38+
# print("Try again with valid combination of tile and release year")

0 commit comments

Comments
 (0)