how to download (dynamically) a file from a particular link using C#

Viewed 365

I know By using WebClient class we can download the files directly. By using this code web.DownloadFile("url", "filename");

But in my scenario I should call this(https://www.nseindia.com/reports/gsm) link and when this link triggered the "Download (.csv)" link should download automatically (you can see this download option in image and highlighted with blue color circle)

Note :

if I click on this download link it starting the downloading in the same link and will not not giving the download link separately. So I should call this download link through the coding only.

So how can we achieve this type of file downloading's.

Give me your best suggestions to achieve this.

This is example of download file

1 Answers

A general approach to solving problems like this:

  • Open the network tab on your browser devtools
  • download the object you want to fetch with your program, and
  • look for the object's download.
  • Inspect that object in the network tab to determine its Url.
  • Then try that URL in your (C#) program.

If you get the object, fine. If you don't, the web site owner may have built anti-scraping protection for the object. For example, you may need to be logged in to the site to access the object.

Related