■ 下载网页源码 (不下载其中的图片flash等) 用什么控件好!要求能 post 数据 比如下载 http://123.com/123.asp?姓名=张&性别=女最好能实现多线程!

解决方案 »

  1.   

    加入timer,commandbutton,text
    private sub command1_click()
    webbrowser1.navigate http://www.sohu.com/
    timer1.enabled=true
    end subprivate sub timer1_timer()
    dim doc,objhtml as object
    dim i as integer
    dim strhtml as stringif 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
      

  2.   

    WebBrowser 控件效果非常不好 他会自己下载 flash 和图片 等浪费网络带宽导致效率极其低下,毫无意义而且用了 time 控件更加导致效率低这个毫无意义!!!
      

  3.   

    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 Long
     
    Private Sub Command1_Click()   Dim sourceUrl As String
       Dim targetFile As String
       Dim hfile As Long
       
       sourceUrl = "http://123.com/123.asp?姓名=张&性别=女"
       targetFile = "c:\temp\xxx.html"
       hfile = URLDownloadToFile(0&, sourceUrl, targetFile, 0&, 0&)
       
    End Sub
      

  4.   

    这个果然不错,非常感谢
    但是
    如果能提供详细的URLDownloadToFile介绍更好
    比如
    如何我知道已经下载完成了?
    如何知道下载的进度?
    如何将下载的文本实时的显示在文本框?
    如何假设下载了一部分已经得到我需要的数据,我要停止下载,然后去下载另一个页面?
    如何知道该连接无效不能下载?
    希望大家教我,我将 100 分送上,如果分数不够,我还有很多!
      

  5.   

    URLDownloadToFile:
    说明:
    Downloads bits from the Internet and saves them to a file.适用于:
    VB4-32,5,6
    声明:
    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 Long 操作系统支持:
    Requires Windows NT 4.0 or later; Requires Windows 95 or later 库文件
    Urlmon 
    参数:pCaller:
    Address of the controlling IUnknown interface of the calling Microsoft?ActiveX?component (if the caller is an ActiveX component). If the calling application is not an ActiveX component, this value can be set to NULL. Otherwise, the caller is a Component Object Model (COM) object that is contained in another component (such as an ActiveX control within the context of an HTML page). This parameter represents the outermost IUnknown of the calling component. The function attempts the download within the context of the ActiveX client framework and allows the caller's container to receive callbacks on the progress of the download. szURL:
    Address of a string value containing the URL to be downloaded. Cannot be set to NULL. szFileName:
    Address of a string value containing the name of the file to create for bits that come from the download. dwReserved:
    Reserved. Must be zero. 
    lpfnCB:
    Address of the caller's IBindStatusCallback interface. URLDownloadToFile calls this interface's IBindStatusCallback::OnProgress method on a connection activity, including the arrival of data. IBindStatusCallback::OnDataAvailable is never called. Implementing IBindStatusCallback::OnProgress allows a caller to implement a user interface or other progress monitoring functionality. It also allows the download operation to be canceled by returning E_ABORT from the IBindStatusCallback::OnProgress call. This can be set to NULL.  
    返回值:
    Returns one of the following values:
    E_OUTOFMEMORY
    The buffer length is invalid or there was insufficient memory to complete the operation. 
    S_OK
    The operation succeeded.  
    具体的解释我就不翻译了
      

  6.   

    试试这个
    用IE来下载
    Private Declare Function DoFileDownload Lib "shdocvw.dll" (ByVal lpszFile As String) As Long
    Private Sub Command1_Click()
       
       Dim sDownload As String
       
       sDownload = StrConv(Text1.Text, vbUnicode)
       Call DoFileDownload(sDownload)
       
    End SubPrivate Sub Form_Load()
    Text1.Text = "http://www.chat.ru/~softdaily/fo-ag162.zip"
    Form1.Caption = "Audiograbber 1.62 Full"
    Text2.Text = "http://www6.50megs.com/audiograbber/demos/cr-ag161.zip"
    End Sub
      

  7.   

    判断该连接无效,你可以用ping的方法
      

  8.   

    难道一个 下载文件 的连接也可以 ping
    而且
    还有很多 ping 不通,但是可以访问的网址
      

  9.   

    比如我要用 URLDownloadToFile 同时下载 10 - n 个文件如何实现如何控制??
      

  10.   

    首先感谢 csdn 的朋友给我指点URLDownloadToFile 非常好用但是出现一个奇怪的现象我用 timer 控件不断的调用 URLDownloadToFile 下载不同的网页速度快得莫名其妙每秒可以下载 10 多个页面(希望真的是这么快就好了)■问题:我的思路'准备下载时 把变量 + 1 说明又多了一个在下载
    Xcs = Xcs + 1
    hfile = URLDownloadToFile(0&, sourceUrl, targetFile, 0&, 0&)
    If hfile = 0 Then '如果下载完成就减少一个
    Xcs = Xcs - 1
    End If我希望借此来控制同时下载的文件数但是代码
    hfile = URLDownloadToFile(0&, sourceUrl, targetFile, 0&, 0&)
    好像根本不需要时间Xcs = Xcs + 1

    Xcs = Xcs - 1
    快得让我难以置信■请问如何构造代码才能在下载之前 +1 下载完成后 -1 ?
    ■问题二
    如何将下载的网页(其实就是文本字符)赋值给一个变量,而不是保存到硬盘上?
    因为如果下载页面较多,将导致频繁写入和读取
    影响运行速度和损伤硬盘
      

  11.   

    ■也许是我调用的方式有问题
    请问有什么好办法同时调用 若干个 URLDownloadToFile 下载不同的页面 ?我希望能达到每秒下载 10-100 个页面请大家给点提示!