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 10 1645
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
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
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
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
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
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
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
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
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
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
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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
...
|
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,...
|
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...
|
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...
|
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...
| |
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |