jay-are
asked on
Capturing text from I.E.
Hello Experts:
I'm interested in capturing the text on a webpage. When I visit the website it displays some dollar amounts at the bottom of the page that I want to capture and store in a sql table if its possible.
Looks like this:
Advertised Price Range for this search
$xx,xxx Highest price
$x,xxx Lowest price
$x,xxx Average price
Is it possible to capture these values? If someone can get me started in the right direction I'd really appreciate it!
I'm interested in capturing the text on a webpage. When I visit the website it displays some dollar amounts at the bottom of the page that I want to capture and store in a sql table if its possible.
Looks like this:
Advertised Price Range for this search
$xx,xxx Highest price
$x,xxx Lowest price
$x,xxx Average price
Is it possible to capture these values? If someone can get me started in the right direction I'd really appreciate it!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for the response. I'll try to work on this tomorrow a.m. and post some questions then about capturing the specific text that I need.
ASKER
What exactly should MsgBox be? I setup a multi-line textbox and did
MsgBox.Text = GetHtmlPage("http://etc")
I had to alter the function as well:
Function GetHtmlPage(ByVal strURL As String) As String
Dim strResult As String
Dim objResponse As WebResponse
Dim objRequest As WebRequest = HttpWebRequest.Create(strU RL)
objResponse = objRequest.GetResponse()
Dim sr As New StreamReader(objResponse.G etResponse Stream())
strResult = sr.ReadToEnd()
sr.Close()
Return strResult
End Function
When I load the page it gives me an object reference error. Not set.
MsgBox.Text = GetHtmlPage("http://etc")
I had to alter the function as well:
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()
sr.Close()
Return strResult
End Function
When I load the page it gives me an object reference error. Not set.
When you open e.g."http://www.google.com" in I.E. you see the page formated
If you right click on the page and select View Source you see the code behind.
GetHtmlPage-->is the code behind
So, you select the portion of the code you want to read from like
dim sStr as string=GetHtmlPage("http://www.google.com")
dim x as integer = instr(sStr,"whatyouarelook ingfor")
sStr=mid(sStr,x+1)
then you eliminate various tags and find/extract the values you want
'
As for the error....
Did you write at the top of your form?
Imports System.IO
Imports System.Net
-also-
I use the code (without your alerting) with Windows.Forms
Are you using it with asp.net?
If you right click on the page and select View Source you see the code behind.
GetHtmlPage-->is the code behind
So, you select the portion of the code you want to read from like
dim sStr as string=GetHtmlPage("http://www.google.com")
dim x as integer = instr(sStr,"whatyouarelook
sStr=mid(sStr,x+1)
then you eliminate various tags and find/extract the values you want
'
As for the error....
Did you write at the top of your form?
Imports System.IO
Imports System.Net
-also-
I use the code (without your alerting) with Windows.Forms
Are you using it with asp.net?
ASKER
I'm using a webform. Vb.net with asp.net. I couldn't use this particular code:
Using
End Using
I just declared sr instead of "Using" and removed the End Using.
I did put the imports in the top of my vb page.
Using
End Using
I just declared sr instead of "Using" and removed the End Using.
I did put the imports in the top of my vb page.
If the code does not work try using the http://#19985351
If this does not do your job, then someone else may help you. I have not much expirience with webforms
If this does not do your job, then someone else may help you. I have not much expirience with webforms
ASKER
Ok well thanks for your help so far!
Thank you jay-are
Dim xmlhttp As Object = CreateObject("MSXML2.Serve
Dim url As String = "http://www.google.com"
xmlhttp.open("POST", url, False)
xmlhttp.setRequestHeader("
xmlHTTP.send()
Dim ViewHTMLCode As String = xmlHTTP.responseText
xmlHTTP = Nothing
MsgBox(ViewHTMLCode)
ViewHTMLCode has html code of google site.
Do some reasearch and isolate the values you want