Python IMDbPY - 搜索关键字
在本文中,我们将了解如何在 IMDb 数据库中搜索关键字。
关键字:它是附加在标题(电影/电视剧/电视剧集)上的一个词(或一组连接词),用于描述在标题期间发生的任何值得注意的对象、概念、风格或动作。关键字的主要目的是让访问者轻松搜索和发现标题。
为了搜索关键字,我们将使用 search_keyword 方法。
Syntax : imdb_object.search_keyword(keyword)
Argument : It takes string as argument which is keyword
Return : It returns list.
下面是实现。
Python3
# importing the module
import imdb
# creating instance of IMDb
ia = imdb.IMDb()
# keyword
keyword = "Delhi"
# searching keyword
search = ia.search_keyword(keyword)
# printing the search
print(search)
Python3
# importing the module
import imdb
# creating instance of IMDb
ia = imdb.IMDb()
# keyword
keyword = "avengers tower"
# searching keyword
search = ia.search_keyword(keyword)
# printing the search
print(search)
输出 :
['delhi', 'delhi-india', 'delhi-university', 'delhi-police', 'delhi-metro', 'delhi-gang-rape', 'new-delhi', 'old-delhi', 'flight-to-delhi', 'new-delhi-india', 'golden-temple-new-delhi', 'reference-to-new-delhi', 'india-gate-new-delhi', 'qutub-minar-delhi', 'chapel-hill', 'drexel-hill', 'institute-for-international-studies-new-delhi', 'model-home', 'model-hobby', 'model-heart', 'model-husband', 'scale-model-house', 'stadelheim-prison', 'reference-to-miguel-hidalgo', 'model-24-stielhandgranate', 'drug-cartel-hid-the-records-in-the-back-of-a-painting', 'university-of-north-carolina-at-chapel-hill', 'reference-to-michael-hinky-dink-kenna', "bazar-de-l'hotel-de-ville-paris", "reference-to-le-musee-de-l'homme-paris"]
Python3
# importing the module
import imdb
# creating instance of IMDb
ia = imdb.IMDb()
# keyword
keyword = "avengers tower"
# searching keyword
search = ia.search_keyword(keyword)
# printing the search
print(search)
输出 :
['avengers-tower']