I'm trying to capture text from a website. I got some previous help here but was unable to get to a working solution. I need to be able to do this from an aspx page using vb.net. This is a WEBFORM. Here is the code I have now:
MsgBox.Text = (GetHtmlPage("http://www.google.com
Function GetHtmlPage(ByVal strURL As String) As String
Dim strResult As String
Dim objResponse As WebResponse
Dim objRequest As WebRequest = HttpWebRequest.Create(strU
objResponse = objRequest.GetResponse()
Dim sr As New StreamReader(objResponse.G
strResult = sr.ReadToEnd()
When I load the page I get the following error:
Object reference not set to an instance of an object.
Exception Details: System.NullReferenceExcept
ion: Object reference not set to an instance of an object.
Line 100: MsgBox.Text = (GetHtmlPage("http://www.google.com
Source File: \\192.168.0.100\wwwroot\97
.aspx.vb Line: 100
How can I get this to work inside my webform? I have to focus on the specific text I need but for now I am just trying to pull the text on an entire page to see if it works. Help!