Downloading Files from Website

Assuming I have a userID and Password, how do I download files from
https://www.stoxx.com/document/CustomisedIndices/Current/Large%20Mid%20Indices
I'd prefer to use a batch file, but C# with .NET 3.5 is OK.
The files need to be downloaded to my hard disk.
AlHal2Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Anil GolamariCommented:
You can use below code base to download the file.

Add using.Net;

  static void fileDownload() {
            WebClient webClient = new WebClient();
            webClient.DownloadFile("https://www.stoxx.com/document/CustomisedIndices/Current/Large%20Mid%20Indices/open_l3700v_20150112.csv", @"C:\Users\anilg_000\Downloads\Test\open_l3700v_20150112.csv");
           
            }

Open in new window

kaufmed   ( ⚆ _ ⚆ )I asked the operating system what I could do to become a better programmer. It said, "Let me give you some pointers."Commented:
I don't believe Windows has a built-in utility like cURL on *nix systems, so I doubt that you can do this solely with a .bat file. You'd either have to install an additional utility like cURL for Windows and use such a utility within a .bat file, use PowerShell, or compile code like the above suggestion.
AlHal2Author Commented:
Thanks Anil.

HI käµfm³d,

I have Windows 7 which I believe comes with Powershell (not sure which version).  Would you have a Powershell script?
Become a CompTIA Certified Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

kaufmed   ( ⚆ _ ⚆ )I asked the operating system what I could do to become a better programmer. It said, "Let me give you some pointers."Commented:
It would really just be a refactoring of Anil Golamari's suggestion into PS syntax:

$client = New-Object System.Net.WebClient
$client.Credentials = New-Object System.Net.NetworkCredential("username", "password")
$client.DownloadFile('https://www.stoxx.com/document/CustomisedIndices/Current/Large%20Mid%20Indices/open_l3700v_20150112.csv', 'C:\Users\anilg_000\Downloads\Test\open_l3700v_20150112.csv')

Open in new window


I haven't tested this, and I don't use PS often, but this should be the correct syntax. If it's not working for you, then post back with the error message and I will try to correct.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
AlHal2Author Commented:
Thanks.
AlHal2Author Commented:
Are you able to download close_natp or close_natp_20151221?
When I download the file it looks funny.
kaufmed   ( ⚆ _ ⚆ )I asked the operating system what I could do to become a better programmer. It said, "Let me give you some pointers."Commented:
What does "looks funny" mean? Are you sure you've given the file the correct extension?
AlHal2Author Commented:
It has html and Javascript.  Goto https://www.stoxx.com/document/CustomisedIndices/Current/Large%20Mid%20Indices/
Search for close_natp_20151221 using Edit\Find and you'll see it.  The file has a csv extension.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows Batch

From novice to tech pro — start learning today.