I'm currently building a website and one of the blocks in the website features upcoming films (for the next week or so). I figured out IMDb is the best place to go to for that.
Problem is, IMDb has no API, and I have no idea on how to extract the data from it and show it the way I want to in my website. After reading a bit online, I saw that I am able to download pages with Ajax and then find and extract the data I need from there. However, that seems very inefficient to me, and I don't know how to find information in the downloaded file.
Is there a better way?
I did this same thing for my app. Since Imdb doesn't have an API, I chose to use www.themoviedb.org. Sign up to get an API key then you can query their service. The docs are located here: http://docs.themoviedb.apiary.io/.
This is inside of a PCL and I used JSON.NET for (de)serialization and I used System.Net.Http for the network calls. Both are nuget packages. You can also use http://json2csharp.com/ to generate your classes from the sample JSON that the service returns.
Example from my app:
private const string basePath = "https://api.themoviedb.org/3/";
private const string apiKey = "<your api key here>";
...
public async Task<IEnumerable<Movie>> GetUpcomingMovies(string title)
{
string url = string.Format("{0}movie/upcoming?api_key={1}", basePath, apiKey);
using (var client = new HttpClient())
{
var result = await client.GetStringAsync(url);
return JsonConvert.DeserializeObject<MovieList>(result).Movies;
}
}
Themoviedatabase also returns the ID for Imdbd. So you could use that to query Imdb. I just opened a new webview in my iOS app and let it open Imdb in a new page if the user wanted to.
webview.LoadRequest(new NSUrlRequest(
new NSUrl(string.Format("http://m.imdb.com/title/{0}", viewModel.ImdbId))));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With