none
Download File using IE RRS feed

  • Question

  • hi all,

    i had a code in the past that used winhttp request to download a file from a website, i played around with the cookies as the website require log-in, but the problem is, that it stopped working, and i am not familiar too much to work with cookies, so i decided to do it with IEautomation, and login using the inspect elements method, now when i get to the link to download the file, how can i make it should do like save target as "C:\users\sample\mypage.csv" ?

    and remember i dont want to use hex keys, well its not the best idea, it will not work always, 

    what can be the most trustable idea to work around with that?

    Monday, January 14, 2013 5:07 AM

Answers

  • sinced i searched all over the internet, i see there is a few ways to download a file from a website using script, but not when you need to log-in, so i will give here what i found, maybe some one can help me figure whats the best way to go,

    1) using winhttp request "it dont support log-in"

    as you can see in this link

    http://www.mrexcel.com/forum/excel-questions/509004-download-xml-file-visual-basic-applications.html

    but there is way by sending cookies, this will not work in my status since the website is very strict, i cant play around with the cookies.

    2) using the windows API function, "also i dont know how to add user name and password to it"

    as you can see in this link

    http://social.msdn.microsoft.com/Forums/en-US/isvvba/thread/beb6fa0e-fbc8-49df-9f2e-30f85d941fad/

    and its also not with log-in first

    3) using ie to log-in but to download you need a big code to get the file from the pop up window, using hex keys, the problem is, its not 100% accurate, which means it may sometimes get stuck, & in my stage i need to have a code which must be very reliable because it can mess up my whole program if its coming in not accurate,

    here is a link for that too.

    http://www.mrexcel.com/forum/excel-questions/507871-download-web-table-multiple-pages.html

    and as i mention , i am looking for a code which should be the most reliable, and i should be able to go in to the website, log-in and then download the file to my pc,

    any help?

    • Marked as answer by Sol Stein Thursday, February 25, 2016 9:28 PM
    Wednesday, January 16, 2013 4:15 PM

All replies

  • Hi Auto2,

    Thank you for posting in the MSDN Forum.

    I've no idea what you're going to do since this forum is about Excel related development issues.

    Please tell me

    1. What kind of project are you working with?
    2. What's your programming language?
    3. By which means you want to realize it?

    I look forward to your reply.


    Quist Zhang [MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, January 15, 2013 5:53 AM
    Moderator
  • ok, sorry i didnt gave all info,

    in basic i have an excel file which have data in it, and when some data reach a certain criteria, it triggers a macro, which is VBA language and it suppose to log-in to a website and then download a csv file and then my excel is getting updated based on that csv file,

    now i used to work with it by sending an own cookie to the website with my credentials, and in that way i was able to get the csv file by using winhttp request, but for security issues i am no longer able to play with the cookies anymore, so in that case, i must use IE to log-in via GetElementsByTagName, but when it comes to go to the link where the file is stored i get stuck, if i navigate ie to that link then i recieve a pop up for save or open, to work with hex keys, i dont think its reliable, i am looking for the most accurate way, the program should work, not getting errors or bugs,

    can you help me with that?

    thanks in advance.

    Tuesday, January 15, 2013 5:24 PM
  • Hi Auto2,

    Thank you for your last reply.

    According to your description, I think your major concern is using VBA to automate IE which is beyond my scope.

    I'll move your thread to Visual Basic for Applications (VBA) forum for better support. Since your issue is about IE automation and you've mentioned words like GetElementsByTagName, I guess you can consult a JavaScript programmer as well.

    Hope it helps.

    Best regards,


    Quist Zhang [MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Wednesday, January 16, 2013 4:55 AM
    Moderator
  • sinced i searched all over the internet, i see there is a few ways to download a file from a website using script, but not when you need to log-in, so i will give here what i found, maybe some one can help me figure whats the best way to go,

    1) using winhttp request "it dont support log-in"

    as you can see in this link

    http://www.mrexcel.com/forum/excel-questions/509004-download-xml-file-visual-basic-applications.html

    but there is way by sending cookies, this will not work in my status since the website is very strict, i cant play around with the cookies.

    2) using the windows API function, "also i dont know how to add user name and password to it"

    as you can see in this link

    http://social.msdn.microsoft.com/Forums/en-US/isvvba/thread/beb6fa0e-fbc8-49df-9f2e-30f85d941fad/

    and its also not with log-in first

    3) using ie to log-in but to download you need a big code to get the file from the pop up window, using hex keys, the problem is, its not 100% accurate, which means it may sometimes get stuck, & in my stage i need to have a code which must be very reliable because it can mess up my whole program if its coming in not accurate,

    here is a link for that too.

    http://www.mrexcel.com/forum/excel-questions/507871-download-web-table-multiple-pages.html

    and as i mention , i am looking for a code which should be the most reliable, and i should be able to go in to the website, log-in and then download the file to my pc,

    any help?

    • Marked as answer by Sol Stein Thursday, February 25, 2016 9:28 PM
    Wednesday, January 16, 2013 4:15 PM