Automating File Download of a link that looks like this: https://www.domain.com/TableData/TableA.csv

耗尽温柔 提交于 2020-01-06 19:49:11

问题


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)

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.

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.


回答1:


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.

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://stackoverflow.com/questions/41859488/automating-file-download-of-a-link-that-looks-like-this-https-www-domain-com

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!