Forum Discussion
How can I pull ratings data from IMDB and place in my excel spreadsheet please?
did anyone ever figure out how to achieve this task? I found a page on the IMDB website that will create an HTML Plugin for any movie on said site. Does anybody know how to use an HTML Plugin from within Excel???
Thanks~ Joey
I was able to do this with Access VBA. Excel VBA should be similar. No plugins are needed, only built-in VBA libraries and functions. The technique I used was web-scraping. Downloading the entire IMDb database like the other user did won't work because (1) IMDb data keep changing, and (2) IMDb DB is huge (gigabytes), so it is better to just get the info you need.
STEP ONE: Declare the URLDownloadToFile function in VBA as shown https://community.coreldraw.com/sdk/f/code-snippets-feedback/62444/downloading-file-from-web. Use it to download the source page of an IMDb title *reference* page (e.g. https://www.imdb.com/title/tt0102926/reference ) to a text file.
STEP TWO: Configure the text file for utf-8 encoding with the VBA code below. Utf-8 is needed for handling many non-English language text (if you deal with a lot of foreign films), otherwise you may get gibberish text in your data.
Set fs = CreateObject("ADODB.Stream")
fs.Charset = "utf-8"
fs.Open
fs.LoadFromFile "C:\MyFolder\DownloadedTextFile.txt"
MyText = fs.ReadText()
STEP THREE: This is the actual web-scraping work. Write a procedure that reads the text file and looks for HTML tags that contain IMDb data. For instance, to look for the IMDb rating, look for this HTML tag:
<span class="ipl-rating-star__rating">8.6</span>
You can use the InStr function or whatever to read what is between the <span> tag and the </span> tag. And that is how you find the rating: 8.6.
This method can be used to obtain just about any data on IMDb: title, year, country, run time, cast & crew, URL of title picture, etc.