简体   繁体   中英

Is there a way to only get the content of the critic review in imdbpy

I just want to get the content part of the critic review in imdbpy without the rest of it is there a way to do this? or do I have to go through the text myself?

provided that you know the movie ID, it's possible to parse just a single page, but beware that for the critic reviews page very little information are available; specifically only "metascore" and "metacritic url" are parsed.

An example, for the movie 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'

The easiest way to get critic review in imdbpy is to use get_movie_critic_reviews method which returns a dictionary.

theMatrix = ia.get_movie_critic_reviews('0133093')

Then you can look at the dictionary using the['data'] key for critic score and external url.

theMatrix['data']

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

I don't understand what you mean by only the contents of the critic review. If you need the text from the external url then should use something like request with beautifulsoup I guess.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM