Connecting Tech Pros Worldwide Forums | Help | Site Map

copy HTML information

Daniel N
Guest
 
Posts: n/a
#1: Aug 23 '06
I am trying to automatically relay information displayed on an HTML page to
my program I am writing in VB.net. I know the window handle, the window
title, and process, but do not know what to do next.



Timo
Guest
 
Posts: n/a
#2: Aug 23 '06

re: copy HTML information



"Daniel N" <DeezNuts@yahoo.comwrote in message
news:myMGg.95$k%3.58@newsfe12.lga...
Quote:
>I am trying to automatically relay information displayed on an HTML page to
>my program I am writing in VB.net. I know the window handle, the window
>title, and process, but do not know what to do next.
>
>
Hope this one helps:

Dim HttpWebReq As System.Net.HttpWebRequest
Dim WebResp As System.Net.HttpWebResponse
Dim WebStream As System.IO.Stream
Dim WebReader As System.IO.StreamReader
Dim PageHTML As String

HttpWebReq = CType(WebRequest.Create("http://www.contoso.com/"),
HttpWebRequest)
WebResp = CType(HttpWebReq.GetResponse(), System.Net.HttpWebResponse)
WebStream = WebResp.GetResponseStream
WebReader = New System.IO.StreamReader(WebStream, Encoding.Default)
PageHTML = WebReader.ReadToEnd
WebResp.Close() ' Close finally to free resources


Daniel N
Guest
 
Posts: n/a
#3: Aug 23 '06

re: copy HTML information


How should I declare WebRequest, HttpWebRequest and Encoding? They come up undeclaured when I copy and paste.

I just wanted to read one section of informaiton from a website, but I dont not know the site address, an executable launches a web app that gives me certian information, and I just wanted to copy that into a string or integer.

Thanks for the help

"Timo" <timo.r.lehtinen@luukku.com
Quote:
Hope this one helps:

Dim HttpWebReq As System.Net.HttpWebRequest
Dim WebResp As System.Net.HttpWebResponse
Dim WebStream As System.IO.Stream
Dim WebReader As System.IO.StreamReader
Dim PageHTML As String

HttpWebReq = CType(WebRequest.Create("http://www.contoso.com/"),
HttpWebRequest)
WebResp = CType(HttpWebReq.GetResponse(), System.Net.HttpWebResponse)
WebStream = WebResp.GetResponseStream
WebReader = New System.IO.StreamReader(WebStream, Encoding.Default)
PageHTML = WebReader.ReadToEnd
WebResp.Close() ' Close finally to free resources

>
Timo
Guest
 
Posts: n/a
#4: Aug 24 '06

re: copy HTML information


Ok. Import namespaces:

Imports System.IO
Imports System.Net
Imports System.Text

that should help. Variable PageHTML will contain the content
of the www-page. Extract the section from it. Replace
"http://www.contoso.com/" with the url you want to access.
However, if you do not know the url then this won't be the
solution you're looking for.

- Timo

"Daniel N" <DeezNuts@yahoo.comwrote in message news:4y0Hg.1$Pz4.0@newsfe09.lga...
How should I declare WebRequest, HttpWebRequest and Encoding? They come up undeclaured when I copy and paste.

I just wanted to read one section of informaiton from a website, but I dont not know the site address, an executable launches a web app that gives me certian information, and I just wanted to copy that into a string or integer.

Thanks for the help

"Timo" <timo.r.lehtinen@luukku.com
Quote:
Hope this one helps:

Dim HttpWebReq As System.Net.HttpWebRequest
Dim WebResp As System.Net.HttpWebResponse
Dim WebStream As System.IO.Stream
Dim WebReader As System.IO.StreamReader
Dim PageHTML As String

HttpWebReq = CType(WebRequest.Create("http://www.contoso.com/"),
HttpWebRequest)
WebResp = CType(HttpWebReq.GetResponse(), System.Net.HttpWebResponse)
WebStream = WebResp.GetResponseStream
WebReader = New System.IO.StreamReader(WebStream, Encoding.Default)
PageHTML = WebReader.ReadToEnd
WebResp.Close() ' Close finally to free resources

>
Nathaniel
Guest
 
Posts: n/a
#5: Aug 24 '06

re: copy HTML information


How do I post that information into like a text box or a string?
"Timo" <timo.r.lehtinen@luukku.comwrote in message news:g_bHg.10315$_P4.7645@reader1.news.jippii.net. ..
Ok. Import namespaces:

Imports System.IO
Imports System.Net
Imports System.Text

that should help. Variable PageHTML will contain the content
of the www-page. Extract the section from it. Replace
"http://www.contoso.com/" with the url you want to access.
However, if you do not know the url then this won't be the
solution you're looking for.

- Timo

"Daniel N" <DeezNuts@yahoo.comwrote in message news:4y0Hg.1$Pz4.0@newsfe09.lga...
How should I declare WebRequest, HttpWebRequest and Encoding? They come up undeclaured when I copy and paste.

I just wanted to read one section of informaiton from a website, but I dont not know the site address, an executable launches a web app that gives me certian information, and I just wanted to copy that into a string or integer.

Thanks for the help

"Timo" <timo.r.lehtinen@luukku.com
Quote:
Hope this one helps:

Dim HttpWebReq As System.Net.HttpWebRequest
Dim WebResp As System.Net.HttpWebResponse
Dim WebStream As System.IO.Stream
Dim WebReader As System.IO.StreamReader
Dim PageHTML As String

HttpWebReq = CType(WebRequest.Create("http://www.contoso.com/"),
HttpWebRequest)
WebResp = CType(HttpWebReq.GetResponse(), System.Net.HttpWebResponse)
WebStream = WebResp.GetResponseStream
WebReader = New System.IO.StreamReader(WebStream, Encoding.Default)
PageHTML = WebReader.ReadToEnd
WebResp.Close() ' Close finally to free resources

>
Closed Thread