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
------------------------------------------------------------------------------------------
Dim dt As HTMLDocument
Set dt = 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怎么获取网页标题
几乎都用它来完成采集任务了!贡献出来啊,很简单滴
Function strCut(strContent, StrStart, StrEnd) As String '通用截取函数
Dim strHtml, S1, S2 As String
dim strstart,strend as string
strHtml = strContent
On Error Resume Next
S1 = InStr(strHtml, StrStart) + Len(StrStart)
S2 = InStr(S1, strHtml, StrEnd)
strCut = Mid(strHtml, S1, S2 - S1)
End Function
Private Sub Form_Load()
Dim hunzi1, hunzi2 As String
hunzi1 = "<html><title>this is title</title></html>"
hunzi2 = strCut(hunzi1, "<title>", "</title>")
MsgBox hunzi2
End Sub
http://tieba.baidu.com/f?kz=255370663