VBA 有办法取得网页内容吗?全文字而不是HTML代码。

来源:百度知道 编辑:UC知道 时间:2024/05/16 12:47:58
如题

你在网上搜索
webBrower控件
有VB的用法
和VBA一样的

Private Sub web_DocumentComplete(ByVal pdisp As Object, url As Variant)

Application.ScreenUpdating = False
Set doc = Web.Document
Dim tex As String
Dim su(1 To 1000, 0)
For Each i In doc.All
Debug.Print TypeName(i) '写类型备查
k = k + 1
' Sheets("temp").Cells(65536, 1).End(xlUp).Offset(1, 0).Value = i.innerText
' Sheets("temp").Cells(65536, 1).End(xlUp).Offset(1, 1).Value = TypeName(i)
' If Not k = 1 Then su(k, 0) = su(k - 1, 0) & vbclrf & i.innerText
tex = tex & vbclrf & i.innerText

If TypeName(i) Like "HTMLHtmlElement" Then MsgBox k: Exit For
Next