下载.pdf文件限制? (Microsoft.XMLHTTP) [英] Download .pdf file limit? (Microsoft.XMLHTTP)

查看:207
本文介绍了下载.pdf文件限制? (Microsoft.XMLHTTP)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Excel 2013中,我在循环中使用下面的VBA代码,每天从网站下载几百个.pdf文件。从星期五(9/21/18)开始,它一直运行良好多年,代码只下载101个文件,然后停止并给出"指定资源的
下载失败"。错误信息。我关闭Excel并在我离开时再次启动该过程,它再执行101个文件并停止。你知道是什么导致了这个以及为什么它刚刚开始发生吗?感谢
的帮助!

In Excel 2013, I'm using the VBA code below in a loop to download a few hundred .pdf files a day from a website. It's been working fine for years then starting on Friday (9/21/18), the code would only download 101 files and then stop and give the "The download of the specified resource has failed" error message. I close Excel and start the process again where I left off and it does another 101 files and stops. Do you have any idea what is causing this and why It just started happening? Thanks for the help!



Dim myURL As String

  myURL ="把你的下载链接放在这里"


Dim myURL As String
 myURL = "Put your download link here"

  Dim HttpReq As Object

 设置HttpReq = CreateObject(" Microsoft.XMLHTTP")

  HttpReq.Open" GET", myURL,False,"username"," password"

  HttpReq.send

 Dim HttpReq As Object
 Set HttpReq = CreateObject("Microsoft.XMLHTTP")
 HttpReq.Open "GET", myURL, False, "username", "password"
 HttpReq.send

  myURL = HttpReq.responseBody

 如果HttpReq.Status = 200则为
    设置oStrm = CreateObject(" ADODB.Stream")

     oStrm.Open

     oStrm.Type = 1

     oStrm.Write HttpReq.responseBody

     oStrm.SaveToFile ThisWorkbook.Path& " \" &安培; " file.csv",2'1 =不覆盖,2 =覆盖

     oStrm.Close

 结束如果

 myURL = HttpReq.responseBody
 If HttpReq.Status = 200 Then
     Set oStrm = CreateObject("ADODB.Stream")
     oStrm.Open
     oStrm.Type = 1
     oStrm.Write HttpReq.responseBody
     oStrm.SaveToFile ThisWorkbook.Path & "\" & "file.csv", 2 ' 1 = no overwrite, 2 = overwrite
     oStrm.Close
 End If

推荐答案

您好,

您的代码中没有包含可见错误。

Your code didn't contain visible errors.

但是,您没有处理所有响应代码 - 您只选择"200 Ok"。其他代码可以告诉你服务器上出了什么问题。

However, You didn't handle all response codes - you picking up only "200 Ok". Other codes can tell you what is wrong on the server.

你用来下载PDF的服务器上最有可能发现你的巨大流量和他们决定通过PC提供101份文件。

Most likely on the server you use to download PDF's was spotted your huge traffic and they decide to provide 101 document by PC. 

为您的PC取另一个IP /用户名/密码,看看发生了什么。

Take another IP/username/password for your PC and see what happend.


这篇关于下载.pdf文件限制? (Microsoft.XMLHTTP)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆