PDA

View Full Version : Pull info from web to access form



endlessracin
08-06-2010, 09:06 AM
Note: I cannot have links so I chopped off the major portion of the links but you should still get the idea I hope.

I searched and read for examples to help me but I have not been able to adapt any of the examples I have found for what I need.

Essentially I am constructing a Access Database for a Movie Collection. I have a form setup with all the nessesary information. Upon entering the Movie Title in the form I allow the user to click the "Download Info" button.

The Download Info button will search the IMDB for the movie title. For example.

strMovieTitle = "Hollow man 2"

I can search the IMDB via:

Set objIE = CreateObject("InternetExplorer.Application")
With objIE
.AddressBar = False
.StatusBar = False
.MenuBar = False
.Toolbar = 0
.Visible = True
.Navigate "find?s=all&q=" & strMovieTitle
End With

While objIE.Busy
Wend
While objIE.Document.ReadyState <> "complete"
Wend

This brings me to a page a results page. Essentially what I want to do is go to the "Titles (Exact Matches)" section of the page and "click" that link or rather take the ID they use which is found in the following link: /title/tt0469916/

MovieID = "tt0469916"

I have tried doing this using commands like:

strMovieTitle = InStr(objIE.Document.Body.innerHTML, "Titles (Exact Matches)")
strMovieTitle = Mid(objIE.Document.Body.innerHTML, strMovieTitle + 50, 100)


But this does not return any of the link information.

I have also tried:

For Each Link In objIE.Document.Links
If (InStr(Link, "/title/")) Then
MovieID = Mid(Link, 26)
End If
Next Link


But this gives me a MovieID = "/tt0164052/"

Which is the wrong MovieID.

After I solve that issue or how to correctly do what I want there. I then want to navigate to the movie page and from there pull all the info about the movie to populate the Access Form for review and storage into the DB.

Can anyone help me? I am new to VBA outside of working with Excel and only its components.

endlessracin
08-10-2010, 04:55 AM
Can anyone help me? Or am I posting this in the wrong thread?

Imdabaum
08-10-2010, 08:17 AM
I wish I could help you, it sounds like a very cool project. But I've never done anything like it. The most I've done with pulling info from the web is downloading files that exist on an ftp site.

gcomyn
08-10-2010, 11:14 AM
here is some code that I came up with that will get you the table for the "Titles (Exact Matches)". however, it will take alot of parsing to get the correct title number... also, you should probably get all of them in the list, and have the user determine which one he/she wants, because my test (Iron Man) was actual the third in the list.


Set objIE = CreateObject("InternetExplorer.Application")
With objIE
.AddressBar = False
.StatusBar = False
.MenuBar = False
.Toolbar = 0
.Visible = True
.navigate "http://www.imdb.com/find?s=all&q=" & strMovieTitle
End With

While objIE.Busy
Wend
While objIE.Document.readyState <> "complete"
lngStart = InStr(1, objIE.Document.Body.innerHTML, "Titles (Exact Matches)")
lngTableStart = InStr(lngStart, objIE.Document.Body.innerHTML, "<table>")
lngTableEnd = InStr(lngTableStart, objIE.Document.Body.innerHTML, "</table>")
strMovieTable = Mid(objIE.Document.Body.innerHTML, lngTableStart, lngTableEnd - lngTableStart + 8)
Debug.Print strMovieTable
Wend


let us know if this helped.

GComyn
:sleuth:

stanl
08-14-2010, 03:32 AM
Can anyone help me? Or am I posting this in the wrong thread?

what you need to do is pre-append the parent to the /title link you find

http://www.imdb.com/title/tt0469916/

so you should set up a parent="http://www.imdb.com"

var in your code so that you MovieID=parent & "/" & title. The correct title should be the href=" immediately following "(Exact Matches)". There are several ways to parse this out, one already suggested. I prefer using DMTML or XPATH.