难以按人口统计提取 IMDb 评级(使用 IMDbpy)

Difficulty extracting IMDb ratings by demographic (with IMDbpy)

我想按人口统计(性别、年龄组)收集 IMDb 评级详细信息。

当我尝试在 imdbpy 中使用 get_movie_vote_details 模块时,我的输出为空。 这是我的代码:

 import imdb

 i =  imdb.IMDb(accessSystem='http')

 movie = i.get_movie('0780504')

 print(movie)

 votes = i.get_movie_vote_details('0780504')

 print(votes)

这是输出:

print(m)

Drive

print(votes)

{'charactersRefs': {}, 'data': {}, 'namesRefs': {}, 'titlesRefs': {}}

如您所见,"votes" 输出有点偏差。有没有一种方法可以使用 imdbpy 提取评级详细信息?

您不应该直接调用 .get_movie_XYZ(...) 方法:它们在内部用于使用 IMDb().update(...) 方法。

例如:

import imdb

i = imdb.IMDb(accessSystem='http')

movie = i.get_movie('0780504')
i.update(movie, 'vote details')
print(movie.get('mean and median')

如果您想知道所有可用的信息集,请致电i.get_movie_infoset();要查看更新给定信息集时添加了 Movie 实例的哪些键,请使用 movie.infoset2key 映射。

有关详细信息,请参阅 official documentation

关于数据的格式,这段代码:

from imdb import IMDb
ia = IMDb()
m = ia.get_movie('0780504', 'vote details')
print('median', m.get('median'))
print('arithmetic mean', m.get('arithmetic mean'))
print('number of votes', m.get('number of votes'))
print('demographics', m.get('demographics'))

将输出如下内容: median 8 arithmetic mean 7.8 number of votes {1: 8626, 2: 4135, 3: 5762, 4: 9264, 5: 17595, 6: 39440, 7: 84746, 8: 133331, 9: 98870, 10: 75737} demographics {'imdb staff': {'rating': 7.8, 'votes': 36}, 'aged under 18': {'rating': 8.5, 'votes': 844}, 'non us users': {'rating': 7.8, 'votes': 250586}, 'top 1000 voters': {'rating': 7.6, 'votes': 739}, 'males aged 45 plus': {'rating': 7.4, 'votes': 24213}, 'aged 45 plus': {'rating': 7.4, 'votes': 28779}, 'aged 18 29': {'rating': 7.9, 'votes': 183217}, 'us users': {'rating': 8.0, 'votes': 71299}, 'aged 30 44': {'rating': 7.7, 'votes': 181063}, 'males aged under 18': {'rating': 8.5, 'votes': 705}, 'males aged 30 44': {'rating': 7.8, 'votes': 152988}, 'females aged under 18': {'rating': 7.9, 'votes': 133}, 'males aged 18 29': {'rating': 8.0, 'votes': 148749}, 'females aged 45 plus': {'rating': 7.4, 'votes': 4004}, 'imdb users': {'rating': 7.8, 'votes': 477506}, 'females aged 18 29': {'rating': 7.6, 'votes': 32575}, 'females': {'rating': 7.6, 'votes': 65217}, 'males': {'rating': 7.9, 'votes': 341617}, 'females aged 30 44': {'rating': 7.5, 'votes': 25465}}