Link to home
Start Free TrialLog in
Avatar of countrymeister
countrymeister

asked on

Download a file from the website using webclient or any other method

I am trying to download a file using a WebClient download file method.
But on one particular site the website requires to select a few button selections after the URL is entered.
How can I a download a file in this case

http://www.blackrock.com/ca/individual/en/products/239839/ishares-sptsx-capped-energy-index-etf/1402045142285.ajax?fileType=csv&fileName=XEG_holdings&dataType=fund

The above url if entered into a browser, requires to select the type of Investor and then hit the Enter site button to download the file

I am using the following code, which works fine for other websites where no user selection is needed.

WebClient webClient = new WebClient();      
 webClient.DownloadFile(downloadFile, downloadLocation);

// download file is the http URL
// downloaded location is some location on the local computer
ASKER CERTIFIED SOLUTION
Avatar of ste5an
ste5an
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi,

I have not tested and i do not know if it would break any of that site's rules, but one thing you could do is see what is the link presented in the button.

For instance i selected the option of being an individual investor. Then the button went green. Then i copied the link location (right click on the button) and got the location of the requested file. Maybe you could use this instead of the given url.

Giannis
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of countrymeister
countrymeister

ASKER

ste5an,

Thank you for letting me know about Fiddler. I was able to see the actual URL after I hit the buttons in fiddler
the URL value does not change in the browser.

Ark,

Thanks for the answer, it was correct what was important to me was how to get to the answer, not just the answer.