自动化文件下载链接,如下所示:https://www.domain.com/TableData/TableA.csv [英] Automating File Download of a link that looks like this: https://www.domain.com/TableData/TableA.csv

查看:343
本文介绍了自动化文件下载链接,如下所示:https://www.domain.com/TableData/TableA.csv的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编写一个将下载.csv和.xls文件的应用程序,并将其保存到稍后由VBA宏访问的文件夹中。在以下链接中未能成功使用该解决方案后,我发布了此问题:如何使用VBA(没有Internet Explorer)下载文件

I am trying to write an application that will download .csv and .xls files and save them into a folder that will be accessed later by a VBA macro. I am posting this question after the unsuccessful use of the solution in the following link: How do i download a file using VBA (Without internet explorer)

宏运行成功,但下载的.csv文件只包含从登录页面的html。我发现这是奇怪的,因为当我将链接直接复制并粘贴到浏览器中而不登录时,我立即提示保存,打开,关闭窗口。

The macro runs successfully, but the downloaded .csv file only contains the html from the login page. I find that strange because when I copy and paste the link directly into the browser without logging in, I am immediately prompted with a save, open, close window for the file.

尽可能地,我尽量避免使用SendKeys,但我似乎找不到另一种解决方案。我不反对VBA以外的选项。任何帮助将不胜感激,谢谢。

As much as possible I am trying to avoid using SendKeys, but I can't seem to find another solution that works. I am not opposed to options other than VBA. Any help would be appreciated, thank you.

推荐答案

您的浏览器存储可能允许您自动登录的cookies。尝试在无痕式浏览器中浏览不同标签页,您可能需要每次登录。

Your browser stores cookies which likely allows you to login automatically. Try browsing the page in different tabs in an incognito browser and you'll likely have to login each time.

您必须找到一种方式来提出相同的请求您的浏览器正在发送到登录,并使用存储的cookies来下载文件的请求。

You'll have to find a way to make the same requests your browser is sending to login, and use the cookies stored to make the requests to download the files.

这篇关于自动化文件下载链接,如下所示:https://www.domain.com/TableData/TableA.csv的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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