Private Sub Command1_Click() Dim webcode$, ListDate$, Str$, i& For i = 1 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) > 3 Then GetHtmlStr = "": Exit Function '判断超出3秒即超时退出过程 Wend If switch = 0 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