download from link in a page with powershell


  1. Posts : 501
    windows 10 (x64) Home 20H2 19042.844
       #1

    download from link in a page with powershell


    I have a page with link as below
    https://www.nseindia.com/companies-l...-announcements

    In that there is a link for downloading a file.
    copy link location of that link shows as "javascript:downloadCSV('CFanncEquity-download')"

    How to make a batch file to download that file
      My Computer


  2. Posts : 6,854
    22H2 64 Bit Pro
       #2

    I don't know about the batch file but just point it to the actual download link:

    Code:
    https://www.nseindia.com/api/corporate-announcements?index=equities&csv=true
      My Computer


  3. Posts : 18,044
    Win 10 Pro 64-bit v1909 - Build 18363 Custom ISO Install
       #3

    Hello @lvgandhi,

    Code:
    start https://www.nseindia.com/companies-l...-announcements

    I hope this helps!
      My Computer


  4. Posts : 3,275
    Win10
       #4

    There is a Powershell "Invoke-WebRequest" utility which is able to directly download hyperlinked files without opening a Browser Window. The only problem is that the CSV link which you want is behind a javascripted link so it is difficult to ge the actual url for it. But, anyway, I tried the YESBANK pdf link which is not behind a javascipted link, and it downloaded fine.

    Powershell script
    Code:
    Invoke-WebRequest -OutFile CFanncEquity.csv -uri "https://www.nseindia.com/api/corporate-announcements?index=equities&csv=true"
    
    Invoke-WebRequest -OutFile YESBANK_29082020222907_test.pdf -uri "https://archives.nseindia.com/corporate/YESBANK_29082020222907_ScheduleofAnalystMeet2908.pdf"

    The first link I have tried in the Powershell is the one shown by @Callender. ( It works if you directly insert that url in a browser but doesn't seem to work with the Powershell Invoke command ).


    ref:
    How to download files from command line in Windows like wget or curl - Super User
    https://docs.microsoft.com/en-gb/pow...w=powershell-7
    Last edited by das10; 29 Aug 2020 at 13:49.
      My Computers


  5. Posts : 501
    windows 10 (x64) Home 20H2 19042.844
    Thread Starter
       #5

    Callender said:
    I don't know about the batch file but just point it to the actual download link:
    Code:
    https://www.nseindia.com/api/corporate-announcements?index=equities&csv=true
    Thanks for your response. It does not work with Invoke-WebRequest -Uri.

    - - - Updated - - -

    Paul Black said:
    Hello @lvgandhi,
    Code:
    start https://www.nseindia.com/companies-l...-announcements
    I hope this helps!
    It starts that web page. But I want to download from a link which uses javascript to download a file.

    - - - Updated - - -

    das10 said:
    There is a Powershell "Invoke-WebRequest" utility which is able to directly download hyperlinked files without opening a Browser Window. The only problem is that the CSV link which you want is behind a javascripted link so it is difficult to ge the actual url for it. But, anyway, I tried the YESBANK pdf link which is not behind a javascipted link, and it downloaded fine.

    Powershell script
    Code:
    Invoke-WebRequest -OutFile CFanncEquity.csv -uri "https://www.nseindia.com/api/corporate-announcements?index=equities&csv=true"
    
    Invoke-WebRequest -OutFile YESBANK_29082020222907_test.pdf -uri "https://archives.nseindia.com/corporate/YESBANK_29082020222907_ScheduleofAnalystMeet2908.pdf"
    The first link I have tried in the Powershell is the one shown by @Callender. ( It works if you directly insert that url in a browser but doesn't seem to work with the Powershell Invoke command ).
    ref:
    How to download files from command line in Windows like wget or curl - Super User
    https://docs.microsoft.com/en-gb/pow...w=powershell-7
    I also used the code as below direct links

    Code:
    $url = "https://www1.nseindia.com/corporates/datafiles/CA_ALL_FORTHCOMING.csv"
    
    $output = ".\CA_ALL_FORTHCOMING.csv"
    Invoke-WebRequest -Uri $url -OutFile $output
    But now problem is downoading from javascript operated link. Any further info will be appreciated.
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 13:44.
Find Us




Windows 10 Forums