Visual Basic .Net -Quick Question

Discussion in 'OT Technology' started by kevlar8, Mar 14, 2005.

  1. kevlar8

    kevlar8 Do or do not, there is no try.

    Joined:
    Jan 31, 2002
    Messages:
    2,163
    Likes Received:
    0
    Location:
    Pittsburgh, PA
    do any of you know if it's possible to have a VB.net program access and search a website such as IMDB and retrieve information from it. Links to tutorials would be greatly appreciated if this is possible.
     
  2. 5Gen_Prelude

    5Gen_Prelude There might not be an "I" in the word "Team", but

    Joined:
    Mar 14, 2000
    Messages:
    14,519
    Likes Received:
    1
    Location:
    Vancouver, BC, CANADA
    I've done something similar using lynx and wget.
     
  3. CompiledMonkey

    CompiledMonkey New Member

    Joined:
    Oct 26, 2001
    Messages:
    8,528
    Likes Received:
    0
    Location:
    Richmond, VA
    You could always send a HTTP request to the server of the page you want data from, then scrape it. Kinda hard to find specifically what you want from the page unless the HTML tags are just tailored for you.
     
  4. Slid.

    Slid. I'm a guy.

    Joined:
    Oct 25, 2001
    Messages:
    1,928
    Likes Received:
    0
    Location:
    NH
    Definately possible...lemme see if I can dig some code up.
     
  5. Slid.

    Slid. I'm a guy.

    Joined:
    Oct 25, 2001
    Messages:
    1,928
    Likes Received:
    0
    Location:
    NH
    Dim gSource As String = getSource("http://www.somewebsite.com/somefile.htm")
    Dim gArray As Array
    Dim i As Integer
    Dim rBuild As String

    'If we can't connect then just exit
    If gSource = vbNullString Then Exit Function

    'Split file into array
    gArray = Split(gSource, Chr(10))

    'Go through config to get commands
    For i = 0 To gArray.Length - 1

    'Get buildid
    If InStr(gArray(i), "buildid=") Then

    rBuild = Mid(gArray(i), 11)

    End If

    Next

    Is some code that I use for an auto-updater I wrote, basically I open a file on the web then split all the lines into an array then step through it looking for what I want. The line of most interest to you is:

    If InStr(gArray(i), "buildid=") Then

    Basically you set that to whatever you are looking for and you're golden, ie. (InStr(gArray(i), "<div>").

    Edit: wow, that code tag really molested by stuff.
     
  6. ahhh back in good ole VB you could create a webbrowser object that gave you complete access to the DOM ... I'd assume there's a .net analog ...
     
  7. Slid.

    Slid. I'm a guy.

    Joined:
    Oct 25, 2001
    Messages:
    1,928
    Likes Received:
    0
    Location:
    NH
    I'm being a noob...getSource is a function I made...lemme get the code for that :)
     
  8. Slid.

    Slid. I'm a guy.

    Joined:
    Oct 25, 2001
    Messages:
    1,928
    Likes Received:
    0
    Location:
    NH
    'This function returns the source of a URL
    Public Function getSource(ByVal URL As String) As String

    On Error Resume Next

    'Set URL
    Dim objResponse As Net.WebResponse
    Dim objRequest As Net.WebRequest
    objRequest = Net.HttpWebRequest.Create(URL)
    objResponse = objRequest.GetResponse()

    'Grab data from URL
    Dim sr As System.IO.StreamReader = New System.IO.StreamReader(objResponse.GetResponseStream())

    'return the source
    Return sr.ReadToEnd()

    End Function
     
  9. kevlar8

    kevlar8 Do or do not, there is no try.

    Joined:
    Jan 31, 2002
    Messages:
    2,163
    Likes Received:
    0
    Location:
    Pittsburgh, PA
    wow. thanks guys, especially Slid. i don't think i am going to include that feature in my program but i enjoyed learning a few things from seeing it.
     

  10. :bigthumb:
     

Share This Page