|
我一般下载文件用下面这段,忘记哪个大佬提供的了
Sub requestimage(picurl$, picname$) '图片url,图片名称
Dim brr() As Byte
With CreateObject("msxml2.serverxmlhttp")
.Open "get", picurl, False
.send
Do Until .Status = 304 Or .Status = 200
DoEvents
If Timer - t >= 5 Then
brr = ""
GoTo 1
End If
Loop
brr = .Responsebody
1:
WriteImage ThisWorkbook.path, brr, picname
End With
End Sub
Private Sub WriteImage(path$, arr() As Byte, index$)
With CreateObject("scripting.filesystemobject")
If Not .FolderExists(path & "\mm") Then '假设保存在mm文件夹中
.createfolder (path & "\mm")
End If
End With
Open path & "\mm\" & Replace(index, "/", "\", , , vbBinaryCompare) For Binary As #1
Put #1, , arr
Close #1
End Sub |
|