vb获取网页的所有元素

前端之家收集整理的这篇文章主要介绍了vb获取网页的所有元素前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
vb获取网页的所有元素
2008-12-11 22:20
vb获取网页的所有元素

原来获取网页的所有元素是这么简单:

Dim theHTML As New HTMLDocument

Set theHTML = wb.document
' wb = ActiveX WebBrowser

' theHTML.All 就是它了!

……所以获得所有链接也就易如反掌了!:
Dim collLink As IHTMLElementCollection

' Get all links
Set collLink = theHTML.All.tags("a")
For i = 0 To collLink.length - 1
Debug.Print "Link " & CStr(i + 1) & ": " & collLink(i) & vbNewLine
Next

相信以后会征服所有的html元素!

http://hi.baidu.com/ok100fen/blog/item/34cdea1d2f27fc8c87d6b62d.html

------------------------------------------------------------------------------------------------------

Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object,URL As Variant)

For Each sform In WebBrowser1.Document.links

List1.AddItem sform

Next

End Sub

-------------------------------------------------------------------------------------------------
Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object,URL As Variant)
Dim x As Long

For x = 0 To WebBrowser1.Document.links.length - 1
Debug.Print WebBrowser1.Document.links.Item(x)
Next x
'length属性返回元素集中元素的个数
Debug.Print "共有" & WebBrowser1.Document.links.length & "个链接。"
End Sub

http://zhidao.baidu.com/question/69780769.html

------------------------------------------------------------------------------------------

DimdtAsHTMLDocument
Setdt=WebBrowser1.Document
Me.Caption=dt.getElementsByTagName("title")(0).innerText ’显示网页链接标题文字信息

http://tieba.baidu.com/f?kz=255370663

【CBM666捕获运行中的网页句柄标题与URL】
http://hi.baidu.com/cbm666/blog/item/9eec33fa9bd5d41ca9d3115d.html

具体:

Private Sub Form_Load()
Inet1.Execute "你的网址 "
End Sub

Private Sub Inet1_StateChanged(ByVal State As Integer)
Dim sTmp As String,sHtml As String
If State = 12 Then
Do
DoEvents
sTmp = Inet1.GetChunk(1024)
If Len(sTmp) = 0 Then Exit Do
sHtml = sHtml + sTmp
Loop
Text1.Text = sHtml
End If
End Sub

这样实现起来很快的。

http://topic.csdn.net/t/20041205/15/3616650.html

用vb怎么获取网页标题

几乎都用它来完成采集任务了!贡献出来啊,很简单滴
FunctionstrCut(strContent,StrStart,StrEnd)AsString'通用截取函数
DimstrHtml,S1,S2AsString
dimstrstart,strendasstring
strHtml=strContent
OnErrorResumeNext

S1=InStr(strHtml,StrStart)+Len(StrStart)
S2=InStr(S1,strHtml,StrEnd)
strCut=Mid(strHtml,S2-S1)

EndFunction

PrivateSubForm_Load()
Dimhunzi1,hunzi2AsString
hunzi1="<html><title>thisistitle</title></html>"
hunzi2=strCut(hunzi1,"<title>","</title>")
MsgBoxhunzi2
EndSub

http://tieba.baidu.com/f?kz=255370663

原文链接:https://www.f2er.com/vb/261661.html

猜你在找的VB相关文章