Pulling HTML Header Data From IMDB

BrianExcel

Well-known Member
Joined
Apr 21, 2010
Messages
975
Good morning folks,

Right now I am using the following code that opens an Internet Explorer Browser window and navigates to a specific title on IMDB using the movie code (such as "tt0118531" for the movie "One Eight Seven").

Code:
Public Sub NavigateToURL(ByVal argURL As String)

  Const READYSTATE_COMPLETE As Integer = 4


  Dim objIE As Object
  
  Set objIE = CreateObject("InternetExplorer.Application")


  With objIE
    .Visible = True
    .Silent = True
    .Navigate argURL
    Do Until .ReadyState = READYSTATE_COMPLETE
      DoEvents
    Loop
  End With


  'objIE.Quit
  Set objIE = Nothing
0
End Sub

This code works fine - but now I need to add a couple more steps.

1. I need to pull the title "One Eight Seven" from the HTML of the IMDB page. I have already located it in the HTML code, shown below:

(open code tag "title")One Eight Seven (1997) - IMDb(closing code tag "/title")

I need to know how to pull that title into column B - column A contains the movie code I referenced above.

2. The next step, is there is an image on that page of the movie cover box. I want to save that image to a folder of my choosing, and name the file as the title that we pulled in step 1.

I was unable to find where the specific image code is, so I am hoping someone can help me with that. Any thoughts from anyone?
 
Last edited:

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
Ok, your first part is:
Code:
Public Function GetMovieTitle(imdbTag As String) As String


With CreateObject("WinHttp.WinHttpRequest.5.1")
    .Open "GET", "http://www.imdb.com/title/" & imdbTag, False
    .send
    GetMovieTitle = Split(Split(.responsetext, "<title>")(1), "</")(0)
End With


End Function

This can be used as a worksheet function:
PHP:
=GetMovieTitle(A1)

Copied down, note it only needs the imdb ref, so if it's the full url you've got you'll need to adapt.

I'll have a look at the image when I get chance :)
 
Upvote 0
Ok I think I broke that post, this forum really doesn't like html, you'll need to remove the # signs from the title tags:

Code:
Function GetMovieTitle(imdbTag As String) As String

With CreateObject("WinHttp.WinHttpRequest.5.1")
    .Open "GET", "http://www.imdb.com/title/" & imdbTag, False
    .send
    GetMovieTitle = Split(Split(.responsetext, "<#title#>")(1), "</")(0)
End With


End Function

Used as a worksheet function

=getMovieTitle(A1) copied down.

I'll have a look at the pic when I get chance :)
 
Upvote 0

Forum statistics

Threads
1,223,246
Messages
6,170,999
Members
452,373
Latest member
TimReeks

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top