我目前正在为一个大学项目做原型设计,我需要知道是否可以使用C ++从imdb.com或rottentomatoes.com获取电影的评级。如果是这样,是否有可能以某种方式单独根据标题搜索该评级?
答案 0 :(得分:1)
最快捷的方法是使用网站https://www.omdbapi.com/
。
您只需发送HTTP请求即可查询有关电影的信息。网站将返回JSON,其中包含有关电影的信息。
示例:
HTTP请求
https://www.omdbapi.com/?t=Ghost
将返回JSON
{
"Title":"Ghost",
"Year":"1990",
"Rated":"PG-13",
"Released":"13 Jul 1990",
"Runtime":"127 min",
"Genre":"Drama, Fantasy, Romance",
"Director":"Jerry Zucker",
"Writer":"Bruce Joel Rubin",
"Actors":"Patrick Swayze, Demi Moore, Whoopi Goldberg, Tony Goldwyn",
"Plot":"After a young man is murdered, his spirit stays behind to warn his lover of impending danger, with the help of a reluctant psychic.",
"Language":"English",
"Country":"USA",
"Awards":"Won 2 Oscars. Another 16 wins & 22 nominations.",
"Poster":"https://images-na.ssl-images-amazon.com/images/M/MV5BMTU0NzQzODUzNl5BMl5BanBnXkFtZTgwMjc5NTYxMTE@._V1_SX300.jpg",
"Ratings":[
{
"Source":"Internet Movie Database",
"Value":"7.0/10"
},
{
"Source":"Rotten Tomatoes",
"Value":"74%"
},
{
"Source":"Metacritic",
"Value":"52/100"
}
],
"Metascore":"52",
"imdbRating":"7.0",
"imdbVotes":"160,136",
"imdbID":"tt0099653",
"Type":"movie",
"DVD":"24 Apr 2001",
"BoxOffice":"N/A",
"Production":"Paramount Pictures",
"Website":"N/A",
"Response":"True"
}
要发送HTTP请求,您可以使用Boost Asio或cpp-netlib(https://github.com/cpp-netlib/cpp-netlib)