怎样用VB的网页自动保存为txt?详细代码。

来源:百度知道 编辑:UC知道 时间:2024/05/21 06:45:16
怎样用VB的网页自动保存为txt?详细代码。

WebBrowser、Timer、CommandButton控件各一个
Private Sub Command1_Click()
WebBrowser1.Navigate "http://www.baidu.com"
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
Open "z:\1.txt" For Output As #1
Print #1, Text1
Close #1
End If

Timer1.Enabled = False
End If

End Sub