If present, the url is accessible
through movie['cover url']. Beware
that it could be missing, so you must
first test it with something like:
if 'cover url' in movie:
...
After that, you can use the urllib
module to fetch the image itself.
To provide a complete example,
something like that should do the
trick:
import urllib
from imdb import IMDb
ia = IMDb(#yourParameters)
movie = ia.get_movie(#theMovieID)
if 'cover url' in movie:
urlObj = urllib.urlopen(movie['cover url'])
imageData = urlObj.read()
urlObj.close()
# now you can save imageData in a file (open it in binary mode).
In the same way, a person's headshot
is stored in person['headshot'].
Things to be aware of:
covers and headshots are available only fetching the data from the web server (via the 'http' or 'mobile' data access systems), and not in the plain text data files ('sql' or 'local').
注意:
。。。
如果由于某种原因你不能使用上面的内容,你可以使用BeautifulSoup之类的东西来获取封面url。
来自IMDbPy邮件列表的响应:
相关问题 更多 >
编程相关推荐