Option ExplicitPrivate Sub Form_Load() WebBrowser1.Navigate "http://www.163.com" End SubPrivate Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant) Dim i As Integer Do Until WebBrowser1.Document.All.Item(i).tagName = "HTML" i = i + 1 Loop Dim s As String s = WebBrowser1.Document.All.Item(i).outerHTML MsgBox s End Sub
tztz520(午夜逛街) 不好下载呀,有没有更好的办法呀
Private Declare Function URLDownloadToFile Lib "urlmon" Alias "URLDownloadToFileA" (ByVal pCaller As Long, ByVal szURL As String, ByVal szFileName As String, ByVal dwReserved As Long, ByVal lpfnCB As Long) As LongFunction GetSou(URL As String) As String Const tmpfile As String = "c:\tmp.sou" URLDownloadToFile 0, URL, tmpfile, 0, 0 Do Until FileLen(tmpfile) DoEvents Loop Dim fn As Integer: fn = FreeFile Open tmpfile For Binary Access Read As #fn GetSou = Space(FileLen(tmpfile)) Get #fn, , GetSou Close #fn Kill tmpfile End FunctionPrivate Sub Command1_Click() MsgBox GetSou("http://www.163.com") End Sub
Debug.Print Inet1.OpenURL("http://www.163.com")
End Sub
WebBrowser1.Navigate "http://www.163.com"
End SubPrivate Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
Dim i As Integer
Do Until WebBrowser1.Document.All.Item(i).tagName = "HTML"
i = i + 1
Loop
Dim s As String
s = WebBrowser1.Document.All.Item(i).outerHTML
MsgBox s
End Sub
Const tmpfile As String = "c:\tmp.sou"
URLDownloadToFile 0, URL, tmpfile, 0, 0
Do Until FileLen(tmpfile)
DoEvents
Loop
Dim fn As Integer: fn = FreeFile
Open tmpfile For Binary Access Read As #fn
GetSou = Space(FileLen(tmpfile))
Get #fn, , GetSou
Close #fn
Kill tmpfile
End FunctionPrivate Sub Command1_Click()
MsgBox GetSou("http://www.163.com")
End Sub