Skip to content

Commit f9d47b5

Browse files
committed
Working on genres
1 parent afb2cec commit f9d47b5

5 files changed

Lines changed: 19 additions & 12 deletions

File tree

.DS_Store

0 Bytes
Binary file not shown.

projects/.DS_Store

0 Bytes
Binary file not shown.

projects/Find_imdb_rating/find_IMDb_rating.py

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010

1111
with open("movies.txt", "r") as file2:
1212
for line in file2:
13-
title = line.lower()
13+
x = line.split(", ")
14+
title = x[0].lower()
15+
release = x[1]
1416
query = "+".join(title.split())
1517
URL = "https://www.imdb.com/search/title/?title=" + query
1618
try:
@@ -24,23 +26,28 @@
2426
name1 = result.h3.a.text
2527
name = result.h3.a.text.lower()
2628
# print(name)
27-
# year = result.h3.find(
28-
# "span", class_="lister-item-year text-muted unbold"
29-
# ).text.lower()
29+
year = result.h3.find(
30+
"span", class_="lister-item-year text-muted unbold"
31+
).text.lower()
3032

31-
if title in name:
33+
# print(name)
34+
# print(year)
35+
# print(release)
36+
37+
if title in name and release in year:
3238
rating = result.find("div",class_="inline-block ratings-imdb-rating")["data-value"]
3339
print(f"Rating of {name1}:", rating)
40+
genres = []
3441
genre = result.p.find("span", class_="genre")
42+
for x in genre:
43+
genres.append(x)
3544
file1.write(name1)
3645
file1.write(',')
3746
file1.write(rating)
38-
file1.write(',')
39-
file1.write(genre)
47+
# file1.write(',')
4048
file1.write('\n')
4149

42-
# for x in genre:
43-
# print(x)
50+
4451

4552

4653
except Exception:
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
Iron Man
2-
Star Wars
1+
Star Wars, 1980
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
Star Wars: Episode IX - The Rise of Skywalker,6.6,
1+
Star Wars: Episode V - The Empire Strikes Back,8.7,
2+
Action, Adventure, Fantasy

0 commit comments

Comments
 (0)