是否有使用IMDbPY提取IMDb评论的方法?

问题描述 投票:-1回答:1

我不需要数据集,该数据集在Kaggle中可用。我想使用IMDbPY或其他任何抓取方法从IMDb中提取电影评论。

https://imdbpy.github.io/

python web-scraping imdb imdbpy
1个回答
0
投票

虽然从imdbpy docs来看不是很明显。您始终可以通过检查变量的键来检查变量的属性。当您使用imdbpy抓取影片时,并非正在寻找的所有信息都不会立即可用。您要获得评论。因此,您必须添加它们。我们可以在信息集中看到三种不同类型的评论。 “评论”,“外部评论”和“评论评论”。与这些关联的密钥尚未添加。下面的示例显示此操作尚未完成。

from imdb import IMDb

# create an instance of the IMDb class
ia = IMDb()

the_matrix = ia.get_movie('0133093')
print(sorted(the_matrix.keys()))

# show all information sets that can be fetched for a movie
print(ia.get_movie_infoset()) #Information we can add. Keys will be added
ia.update(the_matrix, ['external reviews'])
ia.update(the_matrix, ['reviews'])
ia.update(the_matrix, ['critic reviews'])
# show which keys were added by the information set
print(the_matrix.infoset2keys['external reviews']) #no external reviews, so no key is added
print(the_matrix.infoset2keys['reviews']) # A lot of reviews. Adds key: 'reviews'
print(the_matrix.infoset2keys['critic reviews']) #Adds the keys: 'metascore', and 'metacritic url'
# print(the_matrix['reviews'])
print(sorted(the_matrix.keys())) #Check out the new keys that we have added
© www.soinside.com 2019 - 2024. All rights reserved.