-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Clement Osumo
committed
Jun 20, 2023
1 parent
1e7ba2a
commit e8aecc1
Showing
5 changed files
with
59 additions
and
4 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import requests | ||
from bs4 import BeautifulSoup | ||
|
||
|
||
def getOriginalAspectRatio(query): | ||
BASE_URL = "https://www.imdb.com/" | ||
HEADERS = { | ||
'User-Agent': 'Mozilla/5.0 (iPad; CPU OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148'} | ||
|
||
URL = BASE_URL + "find/?q={}".format(query) | ||
searchpage = requests.get(URL, headers=HEADERS) | ||
|
||
soup = BeautifulSoup(searchpage.text, 'lxml') | ||
|
||
if soup.css.select('.ipc-metadata-list-summary-item__t'): | ||
# we have matches, pick the first one | ||
title_url = soup.css.select( | ||
'.ipc-metadata-list-summary-item__t')[0].get('href') | ||
|
||
URL = BASE_URL + title_url | ||
|
||
titlepage = requests.get(URL, headers=HEADERS) | ||
|
||
soup = BeautifulSoup(titlepage.text, 'lxml') | ||
|
||
aspect_ratio_full = soup.find( | ||
attrs={"data-testid": "title-techspec_aspectratio"}).css.select(".ipc-metadata-list-item__list-content-item")[0].decode_contents() | ||
aspect_ratio = aspect_ratio_full.split(':')[0].replace('.', '') | ||
|
||
return aspect_ratio |
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
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