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
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
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.
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?
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.