已安装imdbpy并尝试运行 - http://imdbpy.sourceforge.net/support.html上提到的默认示例,但我无法成功运行它们。
程序:
# Create the object that will be used to access the IMDb's database.
ia = imdb.IMDb() # by default access the web.
# Search for a movie (get a list of Movie objects).
s_result = ia.search_movie('The Untouchables')
# Print the long imdb canonical title and movieID of the results.
for item in s_result:
print item['long imdb canonical title'], item.movieID
# Retrieves default information for the first result (a Movie object).
the_unt = s_result[0]
ia.update(the_unt)
# Print some information.
print the_unt['runtime']
print the_unt['rating']
director = the_unt['director'] # get a list of Person objects.
# Get the first item listed as a "goof".
ia.update(the_unt, 'goofs')
print the_unt['goofs'][0]
# The first "trivia" for the first director.
b_depalma = director[0]
ia.update(b_depalma)
print b_depalma['trivia'][0]
错误:
/System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7 /Users/karan/PycharmProjects/IMDBParser/extractor/imdbpy_tester.py
Untouchables, The (1987) 0094226
Untouchables (in development), The (????) 1987680
"Untouchables, The" (1959) 0052522
"Untouchables, The" (1993) 0106165
Intouchables, The (2011) 1675434
Untouchables, The (2017) 1877895
Untouchable (I) (2016) 5509634
Untouchable 2, The (2001) (VG) 0287778
"Untouchable" (2015) 4191792
Untouchable, The (1997) (VG) 0287779
Untouchable (2012) 2266916
"Untouchable" (2017) (mini) 5220680
Untouchable (I) (2010) 1590231
Untouchable (III) (2013) 3001590
Untouchables, The (1991) (VG) 0335509
"Frontline" The Untouchables (2013) 2620144
"DVD_TV: Enhanced Version" The Untouchables (2005) 1088289
"Real Story, The" The Untouchables (2009) 2760176
"Harbour Lights" The Untouchables (1999) 0596815
"Bill, The" The Untouchables (2000) 0525783
[u'119']
7.9
Traceback (most recent call last):
File "/Users/karan/PycharmProjects/IMDBParser/extractor/imdbpy_tester.py", line 27, in <module>
print the_unt['goofs'][0]
File "/Library/Python/2.7/site-packages/IMDbPY-5.0-py2.7-macosx-10.11-intel.egg/imdb/utils.py", line 1469, in __getitem__
rawData = self.data[key]
KeyError: 'goofs'
Process finished with exit code 1
我发现其他用户在此发布了类似内容 - https://bitbucket.org/alberanid/imdbpy/issues/42/examples-not-functional,但我不知道如何解决此问题。