Downloading Files from Website

AlHal2
AlHal2 used Ask the Experts™
on
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.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
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

ǩa̹̼͍̓̂ͪͤͭ̓u͈̳̟͕̬ͩ͂̌͌̾̀ͪf̭̤͉̅̋͛͂̓͛̈m̩̘̱̃e͙̳͊̑̂ͦ̌ͯ̚d͋̋ͧ̑ͯ͛̉Glanced up at my screen and thought I had coded the Matrix...  Turns out, I just fell asleep on the keyboard.
Most Valuable Expert 2011
Top Expert 2015

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.

Author

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?
Exploring SharePoint 2016

Explore SharePoint 2016, the web-based, collaborative platform that integrates with Microsoft Office to provide intranets, secure document management, and collaboration so you can develop your online and offline capabilities.

Glanced up at my screen and thought I had coded the Matrix...  Turns out, I just fell asleep on the keyboard.
Most Valuable Expert 2011
Top Expert 2015
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.

Author

Commented:
Thanks.

Author

Commented:
Are you able to download close_natp or close_natp_20151221?
When I download the file it looks funny.
ǩa̹̼͍̓̂ͪͤͭ̓u͈̳̟͕̬ͩ͂̌͌̾̀ͪf̭̤͉̅̋͛͂̓͛̈m̩̘̱̃e͙̳͊̑̂ͦ̌ͯ̚d͋̋ͧ̑ͯ͛̉Glanced up at my screen and thought I had coded the Matrix...  Turns out, I just fell asleep on the keyboard.
Most Valuable Expert 2011
Top Expert 2015

Commented:
What does "looks funny" mean? Are you sure you've given the file the correct extension?

Author

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.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial