Skip to content

Commit cd7e7e5

Browse files
committed
Movie and TV ratings scraper - fixing lint with flake8 errors
1 parent 2665088 commit cd7e7e5

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

movie_tv_ratings/movie_tv_ratings.py

+8-6
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import re
33
from bs4 import BeautifulSoup
44

5+
56
# Gets top 250 movies from IMDB
67
def scrape_movies():
78

@@ -14,8 +15,8 @@ def scrape_movies():
1415
for i in range(len(movies)):
1516
movie_string = movies[i].get_text()
1617
movie = (' '.join(movie_string.split()).replace('.', ''))
17-
movie_title = movie[len(str(i))+1:-7]
18-
print(("| " + str(i+1)) + (" | " + movie_title) + (" | Rating : " + "{:.1f}".format(float(ratings[i]))))
18+
movie_title = movie[len(str(i)) + 1:-7]
19+
print(("| " + str(i + 1)) + (" | " + movie_title) + (" | Rating : " + "{:.1f}".format(float(ratings[i]))))
1920
return
2021

2122

@@ -24,7 +25,7 @@ def scrape_tvshows():
2425
page = requests.get("https://www.imdb.com/chart/toptv")
2526
Results = re.findall(r'" alt="(.+?)".*?title="(.*?)".*?strong.*?"(.*?)"', page.text, re.DOTALL)
2627
for i in range(len(Results)):
27-
print("| " + str(i+1) + " | " + Results[i][0] + " | Rating : " + Results[i][-1][:3])
28+
print("| " + str(i + 1) + " | " + Results[i][0] + " | Rating : " + Results[i][-1][:3])
2829

2930
return
3031

@@ -40,12 +41,13 @@ def scrape_tvshows():
4041
if val == 'Movies':
4142
globals()['scrape_movies']()
4243
print("\n")
43-
val = input("Type 'Movies' or 'TV' or 'exit': ")
44+
val = input("Type 'Movies' or 'TV' or 'exit': ")
4445
elif val == 'TV':
4546
globals()['scrape_tvshows']()
4647
print("\n")
47-
val = input("Type 'Movies' or 'TV' or 'exit': ")
48+
val = input("Type 'Movies' or 'TV' or 'exit': ")
4849
elif val == 'exit':
4950
val = ''
5051
else:
51-
val = input("Wrong Input. Try Again: ")
52+
val = input("Wrong Input. Try Again: ")
53+

0 commit comments

Comments
 (0)