473,322 Members | 1,501 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Getting Web Page info

Hello,

I have put together a browser using the AXWebBrowser control. I would like
to access elements of the displayed web page and pass that information back
to the application (say, for example, getting the title (<title>Page
Title</title>) of the page and passing that to a label on the application).
What would be the best method for doing that? Is it even possible?

I may have posted this question before, but I haven't been able to find it
if I have. If so, I am sorry for the repost.

Regards,
Kris
Nov 20 '05 #1
10 1637
Hi Chris,
I used this in an application of mine - place something like the following
code in DocumentComplete of the webbrowser. This assumes that you know what
you want from the web page. I have seen other solutions.

Best wishes

Paul Bromley

Dim HTMLDoc As mshtml.HTMLDocument
Dim elementColl As mshtml.IHTMLElementCollection
Dim element As mshtml.IHTMLElement
Dim sOriginal As String
Dim LinkType As String
Dim StartPosition As Integer
Dim EndPosition As Integer
HTMLDoc = AxWebBrowser1.Document
elementColl = HTMLDoc.all.tags("TBODY")
For Each element In elementColl
sOriginal = element.innerHTML
'ListBox1.Items.Add(sOriginal)
Next element
Dim mName As Match = Regex.Match(sOriginal, "<TD vAlign=top
\?TOP\?><B>Name</B></TD>\s+<TD vAlign=top>.+</TD></TD>",
RegexOptions.IgnoreCase)
Dim iName As Integer
If (mName.Success) Then 'Output match information if a match was found
sName = mName.Value
StartPosition = sName.IndexOf("=top>", 0)
EndPosition = sName.IndexOf("</TD></TD>", 0)
StartPosition = StartPosition + 5
sName = sName.Substring(StartPosition, (EndPosition - StartPosition)) '61 -
Start of Address. 71 = Start of Address +10(Chars to end of text)

"Kris Rockwell" <kr***************************@hybrid-learning.com> wrote in
message news:ee**************@TK2MSFTNGP10.phx.gbl...
Hello,

I have put together a browser using the AXWebBrowser control. I would like
to access elements of the displayed web page and pass that information back to the application (say, for example, getting the title (<title>Page
Title</title>) of the page and passing that to a label on the application). What would be the best method for doing that? Is it even possible?

I may have posted this question before, but I haven't been able to find it
if I have. If so, I am sorry for the repost.

Regards,
Kris

Nov 20 '05 #2
Hi Chris,
I used this in an application of mine - place something like the following
code in DocumentComplete of the webbrowser. This assumes that you know what
you want from the web page. I have seen other solutions.

Best wishes

Paul Bromley

Dim HTMLDoc As mshtml.HTMLDocument
Dim elementColl As mshtml.IHTMLElementCollection
Dim element As mshtml.IHTMLElement
Dim sOriginal As String
Dim LinkType As String
Dim StartPosition As Integer
Dim EndPosition As Integer
HTMLDoc = AxWebBrowser1.Document
elementColl = HTMLDoc.all.tags("TBODY")
For Each element In elementColl
sOriginal = element.innerHTML
'ListBox1.Items.Add(sOriginal)
Next element
Dim mName As Match = Regex.Match(sOriginal, "<TD vAlign=top
\?TOP\?><B>Name</B></TD>\s+<TD vAlign=top>.+</TD></TD>",
RegexOptions.IgnoreCase)
Dim iName As Integer
If (mName.Success) Then 'Output match information if a match was found
sName = mName.Value
StartPosition = sName.IndexOf("=top>", 0)
EndPosition = sName.IndexOf("</TD></TD>", 0)
StartPosition = StartPosition + 5
sName = sName.Substring(StartPosition, (EndPosition - StartPosition)) '61 -
Start of Address. 71 = Start of Address +10(Chars to end of text)

"Kris Rockwell" <kr***************************@hybrid-learning.com> wrote in
message news:ee**************@TK2MSFTNGP10.phx.gbl...
Hello,

I have put together a browser using the AXWebBrowser control. I would like
to access elements of the displayed web page and pass that information back to the application (say, for example, getting the title (<title>Page
Title</title>) of the page and passing that to a label on the application). What would be the best method for doing that? Is it even possible?

I may have posted this question before, but I haven't been able to find it
if I have. If so, I am sorry for the repost.

Regards,
Kris

Nov 20 '05 #3
Thanks Paul, this helps a good deal.

Regards,
Kris

"Paul Bromley" <fl*******@dsl.pipex.com> wrote in message
news:en**************@TK2MSFTNGP09.phx.gbl...
Hi Chris,
I used this in an application of mine - place something like the following
code in DocumentComplete of the webbrowser. This assumes that you know what you want from the web page. I have seen other solutions.

Best wishes

Paul Bromley

Dim HTMLDoc As mshtml.HTMLDocument
Dim elementColl As mshtml.IHTMLElementCollection
Dim element As mshtml.IHTMLElement
Dim sOriginal As String
Dim LinkType As String
Dim StartPosition As Integer
Dim EndPosition As Integer
HTMLDoc = AxWebBrowser1.Document
elementColl = HTMLDoc.all.tags("TBODY")
For Each element In elementColl
sOriginal = element.innerHTML
'ListBox1.Items.Add(sOriginal)
Next element
Dim mName As Match = Regex.Match(sOriginal, "<TD vAlign=top
\?TOP\?><B>Name</B></TD>\s+<TD vAlign=top>.+</TD></TD>",
RegexOptions.IgnoreCase)
Dim iName As Integer
If (mName.Success) Then 'Output match information if a match was found
sName = mName.Value
StartPosition = sName.IndexOf("=top>", 0)
EndPosition = sName.IndexOf("</TD></TD>", 0)
StartPosition = StartPosition + 5
sName = sName.Substring(StartPosition, (EndPosition - StartPosition)) '61 - Start of Address. 71 = Start of Address +10(Chars to end of text)

"Kris Rockwell" <kr***************************@hybrid-learning.com> wrote in message news:ee**************@TK2MSFTNGP10.phx.gbl...
Hello,

I have put together a browser using the AXWebBrowser control. I would like to access elements of the displayed web page and pass that information

back
to the application (say, for example, getting the title (<title>Page
Title</title>) of the page and passing that to a label on the

application).
What would be the best method for doing that? Is it even possible?

I may have posted this question before, but I haven't been able to find it if I have. If so, I am sorry for the repost.

Regards,
Kris


Nov 20 '05 #4
Thanks Paul, this helps a good deal.

Regards,
Kris

"Paul Bromley" <fl*******@dsl.pipex.com> wrote in message
news:en**************@TK2MSFTNGP09.phx.gbl...
Hi Chris,
I used this in an application of mine - place something like the following
code in DocumentComplete of the webbrowser. This assumes that you know what you want from the web page. I have seen other solutions.

Best wishes

Paul Bromley

Dim HTMLDoc As mshtml.HTMLDocument
Dim elementColl As mshtml.IHTMLElementCollection
Dim element As mshtml.IHTMLElement
Dim sOriginal As String
Dim LinkType As String
Dim StartPosition As Integer
Dim EndPosition As Integer
HTMLDoc = AxWebBrowser1.Document
elementColl = HTMLDoc.all.tags("TBODY")
For Each element In elementColl
sOriginal = element.innerHTML
'ListBox1.Items.Add(sOriginal)
Next element
Dim mName As Match = Regex.Match(sOriginal, "<TD vAlign=top
\?TOP\?><B>Name</B></TD>\s+<TD vAlign=top>.+</TD></TD>",
RegexOptions.IgnoreCase)
Dim iName As Integer
If (mName.Success) Then 'Output match information if a match was found
sName = mName.Value
StartPosition = sName.IndexOf("=top>", 0)
EndPosition = sName.IndexOf("</TD></TD>", 0)
StartPosition = StartPosition + 5
sName = sName.Substring(StartPosition, (EndPosition - StartPosition)) '61 - Start of Address. 71 = Start of Address +10(Chars to end of text)

"Kris Rockwell" <kr***************************@hybrid-learning.com> wrote in message news:ee**************@TK2MSFTNGP10.phx.gbl...
Hello,

I have put together a browser using the AXWebBrowser control. I would like to access elements of the displayed web page and pass that information

back
to the application (say, for example, getting the title (<title>Page
Title</title>) of the page and passing that to a label on the

application).
What would be the best method for doing that? Is it even possible?

I may have posted this question before, but I haven't been able to find it if I have. If so, I am sorry for the repost.

Regards,
Kris


Nov 20 '05 #5
Paul,

I have noted that, in my application, using this code results in the
mshtml.HTMLDocument (and other such references) as being "undeclared". Is
there a particular reference I have to add?

Regards,
Kris
"Paul Bromley" <fl*******@dsl.pipex.com> wrote in message
news:en**************@TK2MSFTNGP09.phx.gbl...
Hi Chris,
I used this in an application of mine - place something like the following
code in DocumentComplete of the webbrowser. This assumes that you know what you want from the web page. I have seen other solutions.

Best wishes

Paul Bromley

Dim HTMLDoc As mshtml.HTMLDocument
Dim elementColl As mshtml.IHTMLElementCollection
Dim element As mshtml.IHTMLElement
Dim sOriginal As String
Dim LinkType As String
Dim StartPosition As Integer
Dim EndPosition As Integer
HTMLDoc = AxWebBrowser1.Document
elementColl = HTMLDoc.all.tags("TBODY")
For Each element In elementColl
sOriginal = element.innerHTML
'ListBox1.Items.Add(sOriginal)
Next element
Dim mName As Match = Regex.Match(sOriginal, "<TD vAlign=top
\?TOP\?><B>Name</B></TD>\s+<TD vAlign=top>.+</TD></TD>",
RegexOptions.IgnoreCase)
Dim iName As Integer
If (mName.Success) Then 'Output match information if a match was found
sName = mName.Value
StartPosition = sName.IndexOf("=top>", 0)
EndPosition = sName.IndexOf("</TD></TD>", 0)
StartPosition = StartPosition + 5
sName = sName.Substring(StartPosition, (EndPosition - StartPosition)) '61 - Start of Address. 71 = Start of Address +10(Chars to end of text)

"Kris Rockwell" <kr***************************@hybrid-learning.com> wrote in message news:ee**************@TK2MSFTNGP10.phx.gbl...
Hello,

I have put together a browser using the AXWebBrowser control. I would like to access elements of the displayed web page and pass that information

back
to the application (say, for example, getting the title (<title>Page
Title</title>) of the page and passing that to a label on the

application).
What would be the best method for doing that? Is it even possible?

I may have posted this question before, but I haven't been able to find it if I have. If so, I am sorry for the repost.

Regards,
Kris


Nov 20 '05 #6
Paul,

I have noted that, in my application, using this code results in the
mshtml.HTMLDocument (and other such references) as being "undeclared". Is
there a particular reference I have to add?

Regards,
Kris
"Paul Bromley" <fl*******@dsl.pipex.com> wrote in message
news:en**************@TK2MSFTNGP09.phx.gbl...
Hi Chris,
I used this in an application of mine - place something like the following
code in DocumentComplete of the webbrowser. This assumes that you know what you want from the web page. I have seen other solutions.

Best wishes

Paul Bromley

Dim HTMLDoc As mshtml.HTMLDocument
Dim elementColl As mshtml.IHTMLElementCollection
Dim element As mshtml.IHTMLElement
Dim sOriginal As String
Dim LinkType As String
Dim StartPosition As Integer
Dim EndPosition As Integer
HTMLDoc = AxWebBrowser1.Document
elementColl = HTMLDoc.all.tags("TBODY")
For Each element In elementColl
sOriginal = element.innerHTML
'ListBox1.Items.Add(sOriginal)
Next element
Dim mName As Match = Regex.Match(sOriginal, "<TD vAlign=top
\?TOP\?><B>Name</B></TD>\s+<TD vAlign=top>.+</TD></TD>",
RegexOptions.IgnoreCase)
Dim iName As Integer
If (mName.Success) Then 'Output match information if a match was found
sName = mName.Value
StartPosition = sName.IndexOf("=top>", 0)
EndPosition = sName.IndexOf("</TD></TD>", 0)
StartPosition = StartPosition + 5
sName = sName.Substring(StartPosition, (EndPosition - StartPosition)) '61 - Start of Address. 71 = Start of Address +10(Chars to end of text)

"Kris Rockwell" <kr***************************@hybrid-learning.com> wrote in message news:ee**************@TK2MSFTNGP10.phx.gbl...
Hello,

I have put together a browser using the AXWebBrowser control. I would like to access elements of the displayed web page and pass that information

back
to the application (say, for example, getting the title (<title>Page
Title</title>) of the page and passing that to a label on the

application).
What would be the best method for doing that? Is it even possible?

I may have posted this question before, but I haven't been able to find it if I have. If so, I am sorry for the repost.

Regards,
Kris


Nov 20 '05 #7
Hi Kris,

For the mshtml. you have to set a reference to mshtm in the normal reference
project=>Add.reference->.Net->Microsoft.mshtml

Notice that Paul uses only the tag innerHTML and than start using the regex.
However you can almost get every part from the document because it uses the
Document Object Model DOM.

I hope this helps?

Cor
Nov 20 '05 #8
Hi Kris,

For the mshtml. you have to set a reference to mshtm in the normal reference
project=>Add.reference->.Net->Microsoft.mshtml

Notice that Paul uses only the tag innerHTML and than start using the regex.
However you can almost get every part from the document because it uses the
Document Object Model DOM.

I hope this helps?

Cor
Nov 20 '05 #9
Thanks for the pointer Cor. This will most likely clear things up.

Regards,
Kris
"Cor Ligthert" <no**********@planet.nl> wrote in message
news:ee**************@TK2MSFTNGP11.phx.gbl...
Hi Kris,

For the mshtml. you have to set a reference to mshtm in the normal reference project=>Add.reference->.Net->Microsoft.mshtml

Notice that Paul uses only the tag innerHTML and than start using the regex. However you can almost get every part from the document because it uses the Document Object Model DOM.

I hope this helps?

Cor

Nov 20 '05 #10
Thanks for the pointer Cor. This will most likely clear things up.

Regards,
Kris
"Cor Ligthert" <no**********@planet.nl> wrote in message
news:ee**************@TK2MSFTNGP11.phx.gbl...
Hi Kris,

For the mshtml. you have to set a reference to mshtm in the normal reference project=>Add.reference->.Net->Microsoft.mshtml

Notice that Paul uses only the tag innerHTML and than start using the regex. However you can almost get every part from the document because it uses the Document Object Model DOM.

I hope this helps?

Cor

Nov 20 '05 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Larry Tate | last post by:
I am wanting to get those cool html error pages that ms produces when I hit an error in asp.net. For instance, when I get a compilation error I get an html error page that shows me the ...
1
by: Gunjan Garg | last post by:
Hello All, I am working to create a generic datagrid which accepts a datasource(ListData - This is our own datatype) and depending on the calling program customizes itself for sorting,...
0
by: cnys | last post by:
We have an ASP.NET 2.0 (C#) app and we're trying to add tracing into it. The tracing functionality within .NET is great, but when we output this to a file, it's kind of sparse. So, we're looking...
2
by: rustyc | last post by:
Well, here's my first post in this forum (other than saying 'HI' over in the hi forum ;-) As I said over there: ... for a little side project at home, I'm writing a ham radio web site in...
0
by: buntyindia | last post by:
Hi, I have a very strange problem with my application. I have developed it using Struts. I have a TextBox With Some fixed value in it and on Submit iam passing it to another page. <html:form...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.