Skip to content

Commit c02026d

Browse files
Create imdb.py
Created an imdb app in python for searching and displaying movies along with reviews as a notification on desktop!
1 parent e7bd769 commit c02026d

File tree

1 file changed

+88
-0
lines changed

1 file changed

+88
-0
lines changed

Automation/src/imdb_scraper/imdb.py

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
import requests
2+
3+
from bs4
4+
import BeautifulSoup
5+
6+
print('Enter movie/Tv series name')
7+
8+
movie = input()
9+
10+
print()
11+
12+
url = 'http://www.imdb.com/find?ref_=nv_sr_fn&q=' + movie + '&s=all'
13+
14+
def get_title(movie_url):
15+
16+
source_code = requests.get(movie_url)
17+
18+
plain_text = source_code.text
19+
20+
soup = BeautifulSoup(plain_text, 'lxml')
21+
22+
for title in soup.findAll('div', {
23+
'class': 'title_wrapper'
24+
}):
25+
26+
return title.find('h1').text.rstrip()
27+
28+
source_code = requests.get(url)
29+
30+
plain_text = source_code.text
31+
32+
soup = BeautifulSoup(plain_text, 'lxml')
33+
34+
for td in soup.findAll('td', {
35+
'class': 'result_text'
36+
}):
37+
38+
href = td.find('a')['href']
39+
40+
movie_page = 'http://www.imdb.com' + href
41+
42+
break
43+
44+
movie_name = get_title(movie_page)
45+
46+
def get_movie_data(movie_url):
47+
48+
source_code = requests.get(movie_url)
49+
50+
plain_text = source_code.text
51+
52+
soup = BeautifulSoup(plain_text, 'lxml')
53+
54+
for div in soup.findAll('div', {
55+
'class': 'ratingValue'
56+
}):
57+
58+
print('Imdb rating of the movie/Tv Series "' + movie_name + '" is: ', end = '')
59+
60+
print(div.text)
61+
62+
print()
63+
64+
for div in soup.findAll('div', {
65+
'class': 'summary_text'
66+
}):
67+
68+
print('Summary of the movie/Tv series:')
69+
70+
print(div.text.lstrip())
71+
72+
get_movie_data(movie_page)
73+
74+
''
75+
'print_genre = soup.findAll('
76+
div ',{'
77+
class ':'
78+
subtext '})
79+
80+
for div in print_genre:
81+
82+
for genre in print_genre.findAll('a'):
83+
84+
print(genre.text, end = ' |')
85+
86+
print()
87+
''
88+
'

0 commit comments

Comments
 (0)