inet可以下载网页HTML原码
他下载完网页后怎么做将些原码赋值给一个变量
还有,inet有没有判断当前网页是否下载完毕的工能
谢谢
我用WebBrowser取得网页源码,直接运行正常,但在编译后出错
Private Sub Command1_Click()
WebBrowser1.Navigate "http://www.sdqx.gov.cn/sdcity.php"
End SubPrivate Sub WebBrowser1_DownloadComplete()
'页面下载完毕
Dim doc, objhtml
Set doc = WebBrowser1.DocumentSet objhtml = doc.body.createtextrange() <--------提示这行出错
If Not IsNull(objhtml) Then
Text1.Text = objhtml.htmltext
End IfEnd Sub我用WebBrowser取得网页源码,直接运行正常,但在编译后出错提示:实时错误“91”    Object 变量或 with 块变量没有设置
可能是没有下载完所致,Private Sub WebBrowser1_DownloadComplete()
if webbrowser.busy=false then
Dim doc, objhtml
Set doc = WebBrowser1.DocumentSet objhtml = doc.body.createtextrange()
If Not IsNull(objhtml) Then
Text1.Text = objhtml.htmltext
End If
end if
End Sub

解决方案 »

  1.   

    Private Sub Download(UrtFile As String, LocalFile As String)
    Dim bData() As Byte      '数据变量
    Dim intFile As Integer   '可用文件变量
    Dim i As Integer
    Dim ttt As String
    Inet1.Tag = "Work"
        intFile = FreeFile()      '将 intFile 设置为未使用的文件
        ' OpenURL 方法的结果首先传入 Byte 数组,
        '然后将 Byte 数组保存到磁盘。
        On Error Resume Next
        Kill LocalFile
        On Error GoTo 0
        bData() = Inet1.OpenURL(UrtFile, icByteArray)
        Open LocalFile For Binary Access Write As #intFile
            Put #intFile, , bData()
        Close #intFile
        Inet1.Tag = ""
        Exit Sub
        
    Err1:
    MsgBox "error!"
    Resume
    End Sub这个是生成文本文件的 , 至于怎么读出来 就不用写了吧
      

  2.   

    难道WebBrowser1就没有办法知道是否下载完毕了吗??
      

  3.   

    WebBrowser1.Navigate "http://sell.taobao.com/auction/goods/goods_on_sale.htm"
    WebBrowser1.Silent = True '阻止弹出IE脚本错误
    Do Until WebBrowser1.ReadyState = 4'判断WebBrowser1是否加载完毕
    DoEvents
    Loop'如果没有加载完毕,则反回继续操作