1
- import requests
1
+ import requests #for imdb movie requests.
2
2
3
3
from bs4
4
- import BeautifulSoup
4
+ import BeautifulSoup #Beautifulsoup for desktop notif.
5
5
6
6
print ('Enter movie/Tv series name' )
7
7
8
8
movie = input ()
9
9
10
10
print ()
11
11
12
- url = 'http://www.imdb.com/find?ref_=nv_sr_fn&q=' + movie + '&s=all'
12
+ url = 'http://www.imdb.com/find?ref_=nv_sr_fn&q=' + movie + '&s=all' #imdb's search API.
13
13
14
- def get_title (movie_url ):
14
+ def get_title (movie_url ):
15
15
16
- source_code = requests .get (movie_url )
16
+ source_code = requests .get (movie_url ) #getting movie imdb page url from user input.
17
17
18
- plain_text = source_code .text
18
+ plain_text = source_code .text #convert to plain text
19
19
20
20
soup = BeautifulSoup (plain_text , 'lxml' )
21
21
22
22
for title in soup .findAll ('div' , {
23
23
'class' : 'title_wrapper'
24
24
}):
25
25
26
- return title .find ('h1' ).text .rstrip ()
27
-
26
+ return title .find ('h1' ).text .rstrip ()
28
27
source_code = requests .get (url )
29
28
30
29
plain_text = source_code .text
@@ -35,15 +34,15 @@ def get_title(movie_url):
35
34
'class' : 'result_text'
36
35
}):
37
36
38
- href = td .find ('a' )['href' ]
37
+ href = td .find ('a' )['href' ] #find movie page in imdb
39
38
40
- movie_page = 'http://www.imdb.com' + href
39
+ movie_page = 'http://www.imdb.com' + href
41
40
42
41
break
43
42
44
43
movie_name = get_title (movie_page )
45
44
46
- def get_movie_data (movie_url ):
45
+ def get_movie_data (movie_url ): #getting movie data like reviews and genre.
47
46
48
47
source_code = requests .get (movie_url )
49
48
@@ -55,7 +54,7 @@ def get_movie_data(movie_url):
55
54
'class' : 'ratingValue'
56
55
}):
57
56
58
- print ('Imdb rating of the movie/Tv Series "' + movie_name + '" is: ' , end = '' )
57
+ print ('Imdb rating of the movie/Tv Series "' + movie_name + '" is: ' , end = '' ) #showing movie rating as a desktop notification
59
58
60
59
print (div .text )
61
60
@@ -65,7 +64,7 @@ def get_movie_data(movie_url):
65
64
'class' : 'summary_text'
66
65
}):
67
66
68
- print ('Summary of the movie/Tv series:' )
67
+ print ('Summary of the movie/Tv series:' ) #showing summary of movie as desktop notif.
69
68
70
69
print (div .text .lstrip ())
71
70
@@ -81,7 +80,7 @@ class ':'
81
80
82
81
for genre in print_genre .findAll ('a' ):
83
82
84
- print (genre .text , end = ' |' )
83
+ print (genre .text , end = ' |' ) #showing genre.
85
84
86
85
print ()
87
86
''
0 commit comments