Created
September 23, 2020 14:21
-
-
Save zakirangwala/dcf4b2333eded33ad8db693c32d9a147 to your computer and use it in GitHub Desktop.
Tutorial Code : Get the rotten tomato score of a movie
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Rotten Tomatoes Score | |
def rotten_tomatoes_score(query): | |
try: | |
query += query + " Rotten Tomatoes" | |
URL = google_query(query)[0] | |
page = requests.get(URL, headers=headers) | |
soup = BeautifulSoup(page.content, 'html.parser') | |
res = soup.find(class_='mop-ratings-wrap__percentage').get_text() | |
check = res.split(' ') | |
for i in check: | |
if len(i) > 1: | |
return i | |
except Exception as e: | |
print('Could not retrieve tomatometer score') | |
speak('Could not retrieve tomatometer score') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment