我在网上找到使用rft控件保存webbrowse文本
txtHTML.Text = Webbrowser1.document.body.innerText
´flag :rsftext 保存为txt文件,strtmp文件路径
txtHTML.saveFile strtmp,rtfText
将其name属性设置为web
Private Sub Command1_Click()
End Sub
Private Sub web_DocumentComplete(ByVal pdisp As Object,URL As Variant)
Set doc = web.Document
For Each i In doc.All
Next
End sub
===========================================================================================
转载
´引用 Microsoft HTML Object Library
上面这段儿还附送了其他功能,呵呵。精简一下是这样:
==================================================================================================
我用Webbrowser取得网页源码,直接运行正常,但在编译后出错
Private Sub Command1_Click()
Webbrowser1.Navigate ""
End Sub
Private Sub Webbrowser1_DownloadComplete()
´页面下载完毕
Dim doc,objhtml
Set doc = Webbrowser1.Document
Set objhtml = doc.body.createtextrange()
If Not IsNull(objhtml) Then
Text1.Text = objhtml.htmltext
End If
End Sub
我用Webbrowser取得网页源码,直接运行正常,但在编译后出错
提示:实时错误“91”
可能是没有下载完所致,
Private Sub Webbrowser1_DownloadComplete()
if webbrowser.busy=false then
Dim doc,objhtml
Set doc = Webbrowser1.Document
Set objhtml = doc.body.createtextrange()
If Not IsNull(objhtml) Then
Text1.Text = objhtml.htmltext
End If
end if
End Sub
你要得网页源码用 xmlhttp比较好
先引用 msxml
Dim x As New MSXML2.XMLHTTP
MsgBox StrConv(x.responseBody,vbUnicode)
===============================================================================================
我在网上找到使用rft控件保存webbrowse文本
txtHTML.Text = Webbrowser1.document.body.innerText
´flag :rsftext 保存为txt文件,strtmp文件路径
txtHTML.saveFile strtmp,rtfText
=====================================================================================
Private Sub Webbrowser1_DownloadComplete()
End Sub
使用inet控件
Source1 = Inet1.OpenURL("")
If Source1 <> "" Then
RichTextBox1.Text = Source1
Me.Inet1.Cancel
Else
Source = MsgBox("Source code is not available.",vbinformation,"Source Code")
End If
Private Sub Command1_Click()
End Sub
==================================================================================
加入timer,commandbutton,text
private sub command1_click()
webbrowser1.navigate
timer1.enabled=true
end sub
private sub timer1_timer()
dim doc,objhtml as object
dim i as integer
dim strhtml as string
if not webbrowser1.busy then
set doc=webbrowser1.document
i=0
set objhtml=doc.body.createtextrange()
if not isnull(objhtml) then
text1.text=objhtml.htmltext
end if
timer1.enabled=false
end if
end sub
Dim doc,objhtml As Object
If Not webbrowser1.Busy Then
End If
===================================================================================================
或者试试用InternetReadFile,效果也可以:
Option Explicit
Private Declare Function Internetopen Lib "wininet.dll" Alias "InternetopenA" ( _
Private Declare Function InternetopenUrl Lib "wininet.dll" Alias "InternetopenUrlA" ( _
Private Declare Function InternetReadFile Lib "wininet.dll" ( _
Private Declare Function InternetCloseHandle Lib "wininet.dll" ( _
Private Const INTERNET_FLAG_NO_CACHE_WRITE = &H4000000
Dim s
Private Function GetUrlFile(stUrl As String) As String
End Function
Private Sub Command1_Click()
End Sub
=====================================================================================================
Set vDoc = Webbrowser1.Document ´获取网页的源码 For Each o In vDoc.All DoEvents htmlpage = htmlpage & o.innerHTML Next 然后用写二进制文件的方法将htmlpage的内容写入到.html文件中如果这个网页中含有框架那么要对框加进行处理。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。