代码中存在各种问题和一些错误。
首先,请记住搜索结果不会包含有关电影的任何详细信息:您需要更新存储在 Movie 实例中的信息。
另一个事实是,IMDb 已经改变了它显示情节大纲和概要的方式,现在也包含在情节页面中。
最后要注意的是,代码中有一个小错误,并且在检索概要时,您还会收到一个绝对不应该存在的警告。
代码示例:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from imdb import IMDb
ia = IMDb()
# Search for movie; the results will just have a title and little more
# information.
results = ia.search_movie('Osobennosti natsionalnoy rybalki')
onr = results[0]
print 'Plot from search results: %s' % onr.get('plot outline')
print 'Synopsis from search results: %s' % onr.get('synopsis')
# Update the default information (main page and plot)
ia.update(onr)
print 'Plot after the update: %s' % onr.get('plot outline')
# Update a specific sub-page
ia.update(onr, 'synopsis')
print 'Synopsis after the update: %s' % onr.get('synopsis')
它的输出:
Plot from search results: None Synopsis from search results: None Plot after the update: Synopsis after the update: This synopsis is too short and may not include the required detailed description of the entire plot. We normally require that synopses be at least 10 lines long. If you have seen this title, please help us by improving and expanding this synopsis.
General Ivolgin, forester Kuzmich, and good-natured Lyova lose their way on a fishing trip and wind up in a neighboring country, where they decide to have a good time anyway but end up leaving their vodka and fishing equipment behind.
当然,大纲应该直接从情节大纲页面解析(如果情节大纲丢失,甚至可以使用它来代替它)。请在https://github.com/alberanid/imdbpy/issues中打开错误报告