Steveorevo / node-red-contrib-nbrowser

Provides a virtual web browser (a.k.a. "headless browser") appearing as a node.
35 stars 13 forks source link

How to handle dynamic download link to download a file? #23

Open VignanTej opened 5 years ago

VignanTej commented 5 years ago

A big thumbs-up to the contributers for this amazing node. Makes life a lot easier.

I am not able to understand how to download a file which gets downloaded after clicking the element which is formatted as follows.

`

Export as CSV

                            <i class="glyphicon glyphicon-cloud-download"></i>
                            <span ng-show="csvFailed" class="hide ng-hide">CSV download failed, Please try again.</span>
                        </div>`

This would, after 4-5 seconds start the download in a new pop up window. How can save the downloaded csv?

Steveorevo commented 5 years ago

Did you fill out the onDownload method? From the documentation:

onDownload Use this method to save a downloaded item from the web. Be sure to add this method before the gotoURL method or prior to invoking a download link. file - The path and filename of the item to be downloaded. output - An existing context property to return the download results to or flow output (default). When using a flow output, the download results will be in msg.payload.

VignanTej commented 5 years ago

Yes I tried that. It is not a direct url or link. It runs a JavaScript and opens a new window for the download link. I need to download the file opened in the new window.

On Tue, Jul 23, 2019, 08:48 Stephen J. Carnam notifications@github.com wrote:

Did you fill out the onDownload method? From the documentation:

onDownload Use this method to save a downloaded item from the web. Be sure to add this method before the gotoURL method or prior to invoking a download link. file - The path and filename of the item to be downloaded. output - An existing context property to return the download results to or flow output (default). When using a flow output, the download results will be in msg.payload.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Steveorevo/node-red-contrib-nbrowser/issues/23?email_source=notifications&email_token=AEOHPPH4VC4CAEZ5PHNIBKLQAZ2CDA5CNFSM4IDUUWJ2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD2RZPOQ#issuecomment-514037690, or mute the thread https://github.com/notifications/unsubscribe-auth/AEOHPPAUE3XWEDMNPSF34C3QAZ2CDANCNFSM4IDUUWJQ .

Steveorevo commented 5 years ago

Your best bet is to determine the URL it is attempting to open in a new window and use gotoURL, after the onDownload method.