Python IMDbPY – Searching movies matching with keyword

In this article we will see how we can find movies that have similar keyword. Keyword is a word (or group of connected words) attached to a title (movie / TV series / TV episode) to describe any notable object, concept, style or action that takes place during a title. The main purpose of keywords is to allow visitors to easily search and discover titles.

In order to get movies that have similar keywords we use get_keyword method.

Syntax : imdb_object.get_keyword(keyword)

Argument : It takes string as argument i.e keyword

Return : It return list of movies object



Below is implementation.

filter_none

edit
close

play_arrow

link
brightness_4
code

# importing the module
import imdb
   
# creating instance of IMDb
ia = imdb.IMDb()
   
# keyword
keyword = "marvel"
   
# searching keyword
search = ia.get_keyword(keyword)
  
# pritning the search 
print(len(search))
print(search[0])

chevron_right


Output :

50
Thor: Love and Thunder

Another example

filter_none

edit
close

play_arrow

link
brightness_4
code

# importing the module
import imdb
   
# creating instance of IMDb
ia = imdb.IMDb()
   
# keyword
keyword = "heaven"
   
# searching keyword
search = ia.get_keyword(keyword)
  
# pritning the search 
print(len(search))
print(search[0])

chevron_right


Output :

50
The Good Place (2016–2020))

Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.




My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.