【问题标题】:Is there a way to only get the content of the critic review in imdbpy有没有办法只在 imdbpy 中获取评论评论的内容
【发布时间】:2020-04-23 03:02:29
【问题描述】:

我只想在 imdbpy 中获取评论家评论的内容部分而没有其他内容有没有办法做到这一点?还是我必须自己阅读文本?

【问题讨论】:

标签: python imdbpy


【解决方案1】:

如果您知道电影 ID,则可以只解析一个页面,但请注意,对于评论家评论页面,可用的信息很少;具体来说,只解析“metacore”和“metacritic url”。

一个例子,电影 The Matrix (movieID 0133093)

>>> from imdb import IMDb
>>> ia = IMDb()
>>> m = ia.get_movie('0133093', info='critic_reviews')
>>> m['metascore']
'73'
>>> m['metacritic url']
'https://www.metacritic.com/movie/the-matrix?ftag=MCD-06-10aaa1c'

【讨论】:

    【解决方案2】:

    在 imdbpy 中获得评论评论的最简单方法是使用返回字典的 get_movie_critic_reviews 方法。

    theMatrix = ia.get_movie_critic_reviews('0133093')
    

    然后您可以使用 评论分数和外部 url 的 ['data'] 键。

    theMatrix['data']
    
    #output:
    {'metacritic url': 'https://www.metacritic.com/movie/the-matrix?ftag=MCD-06-10aaa1c',
     'metascore': '73'}
    

    我不明白您所说的仅评论评论的内容是什么意思。如果您需要来自外部 url 的文本,那么我猜应该使用诸如 request with beautifulsoup 之类的东西。

    【讨论】:

    • 是的,我的意思是我只想要评论本身的文字,而不是作者和时间等。无论如何,感谢您的帮助。
    猜你喜欢
    • 2020-05-15
    • 2020-01-09
    • 1970-01-01
    • 2015-12-11
    • 2020-10-28
    • 1970-01-01
    • 2016-01-10
    • 2015-10-28
    • 1970-01-01
    相关资源
    最近更新 更多