Results 1 to 5 of 5

Thread: Reading off of an html document

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2009
    Posts
    4

    Reading off of an html document

    Howdy all,

    I'm a brand new developer, self taught from a book, and I'm having a little trouble with a certain action that I'd like to do. I was hoping to be able to read text off of an html document into Visual Basic for use on an ASP website. I'm specifically using Visual Web Developer 2008, if that matters.

    http://www.willowforkgators.com/news...04results.html

    Is the link of the site that I'm trying to read the text off of, if that matters as well.

    Thanks for any help guys,

    BK

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Reading off of an html document

    Greetings, human. Welcome to VBForums.

    Have a look at HttpWebRequest - this lets you perform a (you guessed it) web request against any resource on the web. In this particular case, you'd do a request against that URL, get the text back as a string, and then start parsing it for the information you need.

    Example: http://msdn.microsoft.com/en-us/libr...ebrequest.aspx

  3. #3

    Thread Starter
    New Member
    Join Date
    May 2009
    Posts
    4

    Re: Reading off of an html document

    Thanks for the quick response. I guess the first thing I needed to know was the name of what I was trying to do, so that was a big help. I found a site that had this
    Imports System
    Imports System.IO
    Imports System.Net
    Module Module1
    Sub Main()
    'Address of URL
    Dim URL As String = http://www.c-sharpcorner.com/default.asp
    Dim request As HttpWebRequest = WebRequest.Create(URL)
    Dim response As HttpWebResponse = request.GetResponse()
    Dim reader As StreamReader = New StreamReader(response.GetResponseStream())
    Dim str As String = reader.ReadLine()
    Do While str.Length > 0
    Console.WriteLine(str)
    str = reader.ReadLine()
    Loop
    End Sub
    End Module

    As an example, but I'm unsure as to where in my aspx.vb code to paste this text.

  4. #4

    Thread Starter
    New Member
    Join Date
    May 2009
    Posts
    4

    Re: Reading off of an html document

    Ok, I figured it out kinda now. The only problem is that I'm still getting an error that Write is not a member of system.net.httpwebresponse, even though I've found many websites on the net that refer to it as being one. Any idea?

  5. #5
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Reading off of an html document

    You can wrap your code in [code] tags so that it's more readable.

    Show your new code, I'm assuming it has changed since the previous post. And you'd put it in your codebehind at the point at which you want it to execute - it could be on page load or a button click.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width