获取网页信息 [英] Getting Web Page info

查看:67
本文介绍了获取网页信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,


我已经使用AXWebBrowser控件组合了一个浏览器。我想

访问显示的网页的元素,并将该信息传回给应用程序(例如,获取标题(< title> Page)

标题< / title>)页面并将其传递给应用程序上的标签。

这样做的最佳方法是什么?甚至可能吗?


我之前可能已经发布过这个问题,但是我还没有找到它

如果我有的话。如果是的话,我很抱歉转发。


问候,

Kris

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

推荐答案

你好Chris,

我在我的应用程序中使用了这个 - 在webbrowser的DocumentComplete中放置类似下面的

代码。这假设你知道你想从网页上得到什么
。我见过其他解决方案。


祝福


Paul Bromley


Dim HTMLDoc as mshtml .HTMLDocument

Dim elementColl as mshtml.IHTMLElementCollection

昏暗元素为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 ElementColl中的每个元素

sOriginal = element.innerHTML

''ListBox1。 Items.Add(sOriginal)

下一个元素

Dim mName As Match = Regex.Match(sOriginal,"< TD vAlign = top

\?TOP \?>< B>名称< / B>< / TD> \s +< TD vAlign = top>。+< / TD>< / TD>",

RegexOptions.IgnoreCase)

Dim iName As Integer

If(mName.Success)Then''输出匹配信息如果a匹配被发现

sName = mName.Value

StartPosition = sName.IndexOf(" = top>",0)

EndPosition = sName.IndexOf("< / TD>< / TD>",0)

StartPosition = StartPosition + 5

sName = sName.Substring(StartPosition, (EndPosition - StartPosition))''61 -

地址开始。 71 =地址开始+10(文字结尾的字符)


" Kris Rockwell" < KR *************************** @ hybrid-learning.com>写在

消息新闻:ee ************** @ TK2MSFTNGP10.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...
你好,
我使用AXWebBrowser控件组合了一个浏览器。我想
访问显示的网页的元素,并将该信息
传回给应用程序(例如,获取标题(< title> Page
Title< / title> ;)页面并将其传递给
应用程序上的标签)。这样做的最佳方法是什么?它甚至可能吗?

我之前可能已经发布过这个问题,但是如果有的话,我还没能找到它。如果是的话,我很抱歉转发。

问候,
Kris
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



嗨Chris ,

我在我的应用程序中使用了这个 - 在webbrowser的DocumentComplete中放置类似下面的

代码。这假设你知道你想从网页上得到什么
。我见过其他解决方案。


祝福


Paul Bromley


Dim HTMLDoc as mshtml .HTMLDocument

Dim elementColl as mshtml.IHTMLElementCollection

昏暗元素为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 ElementColl中的每个元素

sOriginal = element.innerHTML

''ListBox1。 Items.Add(sOriginal)

下一个元素

Dim mName As Match = Regex.Match(sOriginal,"< TD vAlign = top

\?TOP \?>< B>名称< / B>< / TD> \s +< TD vAlign = top>。+< / TD>< / TD>",

RegexOptions.IgnoreCase)

Dim iName As Integer

If(mName.Success)Then''输出匹配信息如果a匹配被发现

sName = mName.Value

StartPosition = sName.IndexOf(" = top>",0)

EndPosition = sName.IndexOf("< / TD>< / TD>",0)

StartPosition = StartPosition + 5

sName = sName.Substring(StartPosition, (EndPosition - StartPosition))''61 -

地址开始。 71 =地址开始+10(文字结尾的字符)


" Kris Rockwell" < KR *************************** @ hybrid-learning.com>写在

消息新闻:ee ************** @ TK2MSFTNGP10.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...
你好,
我使用AXWebBrowser控件组合了一个浏览器。我想
访问显示的网页的元素,并将该信息
传回给应用程序(例如,获取标题(< title> Page
Title< / title> ;)页面并将其传递给
应用程序上的标签)。这样做的最佳方法是什么?它甚至可能吗?

我之前可能已经发布过这个问题,但是如果有的话,我还没能找到它。如果是的话,我很抱歉转发。

问候,
Kris
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



谢谢保罗这很有帮助。


问候,

Kris


" Paul Bromley" < FL ******* @ dsl.pipex.com>在消息中写道

news:en ************** @ TK2MSFTNGP09.phx.gbl ...
Thanks Paul, this helps a good deal.

Regards,
Kris

"Paul Bromley" <fl*******@dsl.pipex.com> wrote in message
news:en**************@TK2MSFTNGP09.phx.gbl...
嗨Chris,

我在我的应用程序中使用了它 - 在webbrowser的DocumentComplete中放置类似下面的代码。这假设你知道
你想从网页上得到什么。我见过其他解决方案。

祝福Paul Bromley

将HTMLDoc视为mshtml.HTMLDocument
Dim elementColl as mshtml.IHTMLElementCollection
昏暗元素为mshtml.IHTMLElement
Dim sOriginal As String
Dim LinkType As String
Dim StartPosition As Integer
Dim EndPosition As Integer
HTMLDoc = AxWebBrowser1。文档
elementColl = HTMLDoc.all.tags(" TBODY")
For ElementColl中的每个元素
sOriginal = element.innerHTML
''ListBox1.Items.Add(sOriginal)
下一个元素
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)然后''如果找到匹配则输出匹配信息
sName = mName.Value
StartPosition = sName.IndexOf(" = top>",0)
EndPosition = sName.IndexOf("< / TD>< / TD>",0)
StartPosition = StartPosition + 5
sName = sName.Substring(StartPosition,(EndPosition) - StartPosition))
''61 - 地址开始。 71 =地址开始+10(字符结尾的字符)

Kris Rockwell < KR *************************** @ hybrid-learning.com>在消息新闻中写了
:ee ************** @ TK2MSFTNGP10.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...
你好,
我使用AXWebBrowser控件组装了一个浏览器。我想
喜欢访问显示的网页的元素并将该信息
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


传回

到应用程序(例如,获取标题(< lt) ;标题>页面
标题< / title>)并将其传递给
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).

什么是最好的方法这样做?它甚至可能吗?

我之前可能已经发布过这个问题了,但是如果有的话,我还没能找到
。如果是的话,我很抱歉转发。

问候,
Kris
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




这篇关于获取网页信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆