Skip to content

Commit 2d5a3bf

Browse files
authored
Finds out the Top 250 Movies on IMDB
1 parent 640fcb9 commit 2d5a3bf

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

IMDB_Scraping.py

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#IMDB Scraping
2+
'''Script that finds the Top 250 Movies on IMDB.'''
3+
import requests
4+
import bs4 as bs
5+
6+
#List that stores the details of the movies as a Dictionary.
7+
movies = []
8+
print('Scraping in Progress... ')
9+
10+
for idx in range(1,4):
11+
url = 'https://www.imdb.com/list/ls068082370/?sort=list_order,asc&st_dt=&mode=detail&page=' + str(idx)
12+
response = requests.get(url)
13+
html = response.text
14+
soup = bs.BeautifulSoup(html, 'lxml')
15+
16+
temp = soup.findAll('div', class_= 'lister-item mode-detail')
17+
18+
19+
for i in temp:
20+
d = dict()
21+
22+
d['Title'] = i.find('h3', class_= 'lister-item-header').find('a').text
23+
d['Rating'] = i.find('span', class_= 'ipl-rating-star__rating').text
24+
d['Director'] = i.select_one("p:nth-of-type(3)").find('a').text
25+
26+
stars = [i.select_one("p:nth-of-type(3)").select_one("a:nth-of-type(2)").text,
27+
i.select_one("p:nth-of-type(3)").select_one("a:nth-of-type(3)").text]
28+
d['Actors'] = stars
29+
30+
31+
movies.append(d)
32+
33+
print(len(movies))

0 commit comments

Comments
 (0)