perl2008 has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks -- I am in desparate need for your help. I am trying to get a PDF file from a secured site by using Perl:Mechanize. When I click on that file, a "File Download" popup appears with buttons "Open", "Save" "Cancel" and if "Save" is selected then another popup window "Save As" appears with "File name:" & "Save as type:" along with "Save" & "Cancel" buttons. How do I handle these using Perl:Mechanize? Thanks a lot.

Replies are listed 'Best First'.
Re: Popup Window
by bart (Canon) on Nov 18, 2008 at 20:26 UTC
    Is that really a popup window (composed in HTML), or instead, a "File Save" dialog? I suspect it's the latter, in which case you can skip that step. Actually, likely the previous "popup" is a browser dialog box too.

    The click on "File Download" will probably have the server transfer the data of the PDF file to you, and all you have to do is save that data to a file. According to the docs for WWW::Mechanize and LWP::UserAgent, you just need to use the methodget on the mech object and specify the path of the file you want to save it in.

    HTH.

Re: Popup Window
by CountZero (Bishop) on Nov 27, 2008 at 21:57 UTC
    Perl::Mechanize? I don't think that module exists.

    And in case you meant WWW::Mechanize, it doesn't pop up windows or dialogs ...

    CountZero

    A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James