Question Search website, return text of another webpage

Haxaro

Well-known member
Joined
Mar 13, 2009
Messages
105
Programming Experience
1-3
I am making an application that will save all the names of the movies in my "movies" folder on my computer. I am able to make a list of all the names quite easily, but how would it be possible for me to search The Internet Movie Database (IMDb) for the title of the movie, click on the link of the name of the movie and grab information of the movie off the imdb database (Run time, rating, and plot?) i have no idea how i can automatically do this. Please help :)
 
Hi, I've dont little research on this my self in the past for certain projects, by the sounds of it you'll need to do some parsing, here a bit of info on that, maybe this is what your looking for:

MSDN How to: Create Web Services That Parse the Contents of a Web Page

have a look, and see what you think?, Hope this helps :)
 
Hi i hope this is what your looking for if not, then it was a waste of my time, not that it's your fault lol, i enjoyed doing it anyway, so here goes, File Is Attached, All Source enJoy! :)
 
Last edited:
Wow. thats perfect. thank you so much :) +Rep

Except, how could i return the Year, Rating and plot aswell just quickly?
 
lol, you would need to parse the HTML Page source it's self, i did it tiney sample in the Program i made, but you will have to, extend it more for your need or make a seperate parsing function for each part you need parsing.

MSDN Int32.Parse Int32.Parse Method (String) (System)

MSDN WebRequest WebRequest Class (System.Net)

MSDN Int32..::.Parse Method (String, IFormatProvider) Int32.Parse Method (String, IFormatProvider) (System)

if none of the above is clear, just do a general Search on the INet looking up KeyWords:
Int32
inStr - inStrRev
Parse HTML
Parse String

with enough reading and looking at examples you will get the hang of it, hope this helps :)
 
Could you give me a sample, i would only need one because i could alter the code as i need it.

I made an app before with this:
VB.NET:
For Each span As HtmlElement In Me.WebBrowser1.Document.GetElementsByTagName("span")
    If span.GetAttribute("id").StartsWith("ls_contents-") Then
        Me.ListBox1.Items.Add(span.InnerText.Trim)
    End If
Next

but i cant seem to get it to work here.
 
ok here goes i re' looked at the program and added alot more, not all my own work as i have my own projects to work on so i search the MSDN Librar at Microsoft, I removed the other files and now reAttaching it here, with new code added for you, i hope this help you what you need as the required code needed for what you want is right in their, just needs tweeking :)
 

Attachments

  • WeBSearch.zip
    17.2 KB · Views: 26
oh yes i removed the binarys "*.exe" files as the forum requires it, i did a boo boo and left them in the last project, sorry for that :)
 
Thats still great, but i can only get the title and the description of the movie. is there a way to get the class INFO for rating and run time?

sorry :p
 
lol, ok with that code their yes you can, you just have to change the value to what you need, theirs not much i can do for you, as its all their, just needs changing to what you need, how you want it to parse the page, if your still finding this hard to grasp then i suggest you do some reading as i formentioned :D, as Knowledge Is Power, I have faith in you, that you can Tweek The Code For You Benefit :D
 
Doing something like this does not work though..

VB.NET:
If (webDisplay.Document IsNot Nothing) Then
            Dim Elems As HtmlElementCollection
            Dim WebOC As WebBrowser = webDisplay

            Elems = WebOC.Document.GetElementsByTagName("CLASS")

            For Each elem As HtmlElement In Elems
                Dim NameStr As String = elem.GetAttribute("info")

                If ((NameStr IsNot Nothing) And (NameStr.Length <> 0)) Then
                    If NameStr.ToLower().Equals("title") Then
                        Dim ContentStr As String = elem.GetAttribute("Parents Guide")
                        MessageBox.Show("Document: " & WebOC.Url.ToString() & vbCrLf & "Title: " & ContentStr)
                    End If
                End If
            Next
        End If
 
ok Form Element i think for the runtime is Runtime: and for the user Rating is User Rating:

for the code to work you have to make sure you put in the right elements for it to find and grab the info needed, try looking at the page source in your browser see if you can get any idea on what you need als look at the output in the rchContents box on the form as it's downloaded their too :)
 
ok i found this pack, Html Agility Pack seems to do the parsing for to, to what ends im unsure as i haven't tested this, just came across it in a quick search on the INet, lets hope this helps :)
 
Back
Top