|
请教老师,我用第三种方法抓图片,抓一个,成功了,但是我现在有很多图片的网址,我想设置一个循环,让这个程序自动的一个一个的抓。但是好像失败了,提示:拒绝的权限,错误70。
请教老师,这个该怎么解决啊?
一下是我的代码:
Sub HttpDownNetFile()
Dim nUrl As String, localFilename As String
Dim XmlHttp As Object, ayrHttpBody() As Byte
Dim c As Range
For Each c In Worksheets("keyboard").Range("b2:b298") ’我的网址就在这个单元格里
nUrl = c.Value
localFilename = ThisWorkbook.Path & c.Row & ".png"
Set XmlHttp = CreateObject("Microsoft.XMLHTTP")
XmlHttp.Open "GET", nUrl, False '异步下载
XmlHttp.Send
Do Until XmlHttp.ReadyState = 4
DoEvents
Loop
If XmlHttp.Status = 200 Then
ayrHttpBody() = XmlHttp.ResponseBody
Open localFilename For Binary As #1
Put #1, , ayrHttpBody()
Close #1
MsgBox "成功"
Else
MsgBox "失败"
End If
Set XmlHttp = Nothing
Next
End Sub |
|