imDbPy 示例不工作:'key error'
imDbPy Example not working: 'key error'
我从 imDbPy 页面复制了示例。
# 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.
我现在遇到这个关键错误:
Traceback (most recent call last):
File "C:\Artificial Intelligence\Machine Learning\movie_classification.py", line 76, in <module>
print(the_unt['runtime'])
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\imdb\utils.py", line 1467, in __getitem__
rawData = self.data[key]
KeyError: 'runtimes'
[Finished in 3.6s with exit code 1]
[shell_cmd: python -u "C:\Artificial Intelligence\Machine Learning\movie_classification.py"]
[dir: C:\Artificial Intelligence\Machine Learning]
[path: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\bin;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\libnvvp;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\dotnet\;C:\Program Files\Microsoft SQL Server0\Tools\Binn\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64;C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\Scripts;C:\Program Files (x86)\GtkSharp.12\bin;C:\Users\lordp\AppData\Local\Microsoft\WindowsApps;]
据我了解,'runtimes' 不作为键存在。
我可以使用的键是这些 (the_unt.keys()):
['title', 'kind', 'year', 'akas', 'plot', 'canonical title', 'long imdb title', 'long imdb canonical title', 'smart canonical title', 'smart long imdb canonical title']
但是从网上说的我应该有更多的选择。
据我所知,我正确安装了 imDbPy。
有人知道这个问题吗?
不幸的是,最近对 IMDb 网站网页的更改破坏了大部分 IMDbPY。请参阅此讨论:https://github.com/alberanid/imdbpy/issues/103
不幸的是,除了使用 http://www.imdb.com/interfaces/
提供的(少数)数据外,您无能为力
我从 imDbPy 页面复制了示例。
# 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.
我现在遇到这个关键错误:
Traceback (most recent call last):
File "C:\Artificial Intelligence\Machine Learning\movie_classification.py", line 76, in <module>
print(the_unt['runtime'])
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\imdb\utils.py", line 1467, in __getitem__
rawData = self.data[key]
KeyError: 'runtimes'
[Finished in 3.6s with exit code 1]
[shell_cmd: python -u "C:\Artificial Intelligence\Machine Learning\movie_classification.py"]
[dir: C:\Artificial Intelligence\Machine Learning]
[path: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\bin;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\libnvvp;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\dotnet\;C:\Program Files\Microsoft SQL Server0\Tools\Binn\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64;C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\Scripts;C:\Program Files (x86)\GtkSharp.12\bin;C:\Users\lordp\AppData\Local\Microsoft\WindowsApps;]
据我了解,'runtimes' 不作为键存在。
我可以使用的键是这些 (the_unt.keys()):
['title', 'kind', 'year', 'akas', 'plot', 'canonical title', 'long imdb title', 'long imdb canonical title', 'smart canonical title', 'smart long imdb canonical title']
但是从网上说的我应该有更多的选择。
据我所知,我正确安装了 imDbPy。 有人知道这个问题吗?
不幸的是,最近对 IMDb 网站网页的更改破坏了大部分 IMDbPY。请参阅此讨论:https://github.com/alberanid/imdbpy/issues/103
不幸的是,除了使用 http://www.imdb.com/interfaces/
提供的(少数)数据外,您无能为力