Chinaunix首页 | 论坛 | 博客
  • 博客访问: 201673
  • 博文数量: 106
  • 博客积分: 3810
  • 博客等级: 中校
  • 技术积分: 1007
  • 用 户 组: 普通用户
  • 注册时间: 2009-03-18 13:35
文章分类

全部博文(106)

文章存档

2014年(17)

2011年(5)

2010年(75)

2009年(9)

我的朋友

分类: Windows平台

2014-03-20 10:15:57

知道里有人问了我就回答下,顺便赚点分数 

普通的东东我还懒得回答呢,看了2个分类达人的回答,一个用webbrowser一个用渣api 笑死我了

看我的王道-xmlhttp

Private Sub Command1_Click()
    
Dim webcode$, ListDate$, Str$, i&
    
For i = To List1.ListCount
        ListDate = List1.List(i - 
1)
        Str = Mid(ListDate, InStrRev(ListDate, 
"."))
        
If Str = ".jpg" Or Str = ".bmp" Or Str = ".gif" Then
            Call 
GetHtmlStr(ListDate, 0, (i - 1) & Str)
        
Else
            
webcode = GetHtmlStr(ListDate, 1)
            Open App.Path & 
"\" & i & Str & "" For Append As #1
                
Print #1, webcode
            Close 
#1
        
End If
    Next
End Sub
                                                                         
Private Function 
GetHtmlStr$(StrUrl$, switch%, Optional ii$)             
'获取源码
    
Dim XmlHttp
    
Set XmlHttp = CreateObject("Microsoft.XMLHTTP")
    XmlHttp.Open 
"GET", StrUrl, True
    
XmlHttp.send
    stime = Now                                                                
'获取当前时间
    
While XmlHttp.ReadyState <> 4
        
DoEvents
        ntime = Now                                                            
'获取循环时间
        
If DateDiff("s", stime, ntime) > Then GetHtmlStr = ""Exit Function  '判断超出3秒即超时退出过程
    
Wend
    
If switch = Then
        Dim 
Buff() As Byte
        
Buff = XmlHttp.ResponseBody
        Open App.Path & 
"\" & ii & "" For Binary As #1
            
Put #1, , Buff
        Close 
#1
    
Else
        
GetHtmlStr = StrConv(XmlHttp.ResponseBody, vbUnicode)
    
End If
    Set 
XmlHttp = Nothing
End Function
                                                                    
Private Sub 
Form_Load()
    List1.AddItem
"http://www.sunshinebean.com/blog/fckeditor/editor/images/smiley/qq2007/21.gif"
    
For i = To 65
        
List1.AddItem "http://www.sunshinebean.com/blog/article/& i & ".htm"
    
Next
    
List1.AddItem ""
End Sub


下载速度不是一般的快哈哈~~而且你文件什么格式下载下来就啥格式的

还支持图片格式下载 
阅读(373) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~