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

Hi,

I've used Super Search for this...and only after not getting a satisfactory answer am i posting this:

I've a website with Javascript...I used IE::Mechanize to login and fill the forms..till i reach a page where on submitting a form, i get to download a file(report). This then asks me a question "Save or open the page..."

I'm not sure how to download that file using this module from the script. It is not a "href" and so i do not know it's url...+ it runs some javascript with some hidden parameters.

Any help is appreciated.

Exasperated

Imrags

Replies are listed 'Best First'.
Re: Win32::IE::Mechanize download file
by Lawliet (Curate) on Jul 27, 2008 at 20:15 UTC
      Sounds to me like the module in question here is Win32::IE::Mechnize, not WWW::Mechanize, so unless IE has been configured to disable JavaScript, this should not be a problem. At this point we don't know if the form in question contains any JavaScript, it may just be doing a redirect to a URL based on form criteria. From what the OP mentioned in the CB, this was a case of a new window opening with the IE 'Save as'/'Open With' dialogue box.

      Thanks

      Martin
        I have the request headers and the Location: Now what can be done so that i get the data????

        LOCATION:: http://website_name/export/download.jsp?t=csv&f=/ccexport/fs076/se1102186454649.csv
        Request headers: Host: website_name.com User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1 +6) Gecko/20080702 Firefox/2.0.0.16 Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9 +,text/plain;q=0.8,image/png,*/*;q=0.5 Accept-Language: en-us Accept-Encoding: gzip,deflate Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 Keep-Alive: 300 Connection: keep-alive Referer: http://website_name.com/rnavmap/evaluate.rnav/pidEjc9NdNrtXuC +EdiuJgbZpwf57?activepage=subscriber.activity&action=export&uid=110218 +6454649 Cookie: mbox=PC#1217149956640-344459.05#1280338508|geo#1#1280338508|se +ssion#1217266506140-54222#1217268367|check#true#1217266567|edge#app6- +prod5.prod5.offermatica.com.1217266473358#1217266508; sops=1101500533 +487#1=O#2=A#3=O#4=A#; s_vi=[CS]v1|488C3C0400004D96-A3A096600000468[CE +]; __utmz=152702054.1217149964.1.1.utmccn=(direct)|utmcsr=(direct)|ut +mcmd=(none); cclp_split=sc_01_ts=4501752|sc_01=200806_Award::Recipe B +: You|; cclp_content=lp_uid=20080727_05:12:25.279_8EwuoNSSUMx28IshuRq +sBsz_P1-WS031|; cclp_partner=prt_02_ts=4501918|prt_05_ts=4503694|prt_ +01_ts=4501752|prt_04_ts=4503366|prt_05=partner.name::ROVING|prt_04=pa +rtner.name::ROVING|prt_03_ts=4502980|prt_03=partner.name::ROVING|prt_ +02=partner.name::ROVING|prt_01=partner.name::ROVING|; cclp_referral=p +artner=ROVING|pn=ROVING|sitereferrer=http://website_name.com/login.js +p|partner.name=ROVING|; __utma=152702054.1731584802.1217149964.121724 +6826.1217266509.5; JSESSIONID=0000Ejc9NdNrtXuCEdiuJgbZpwf:-1; pid=-1; + __utmc=152702054; s_cc=true; s_sq=%5B%5BB%5D%5D<
      is there a way to capture the window that pops up and says "Open the file" or "Save as"...
Re: Win32::IE::Mechanize download file
by Gangabass (Vicar) on Jul 28, 2008 at 02:09 UTC

    It sounds like target web page has some Javascript which redirect you. You need some tools to find what's happens. Try to use LiveHTTPHeaders extension of Firefox to look into HTTP headers.

    After that you can just use redirection URL in your script.

      a part of the html code which i think is relevant...

      <form name="subscriber.export" method="post" action="/something/someth +ing/pidXMxhf8BvVhiTih9LIxLqC-s81"> <input type="hidden" name="activepage" value="subscriber.export"> <input type="hidden" name="pageName" value="subscriber.export"> <input type="hidden" name="uid" value="11021864546"> <input type="hidden" name="filename" value="NXwC0VHkO3tkyOfknRf0vu +xuOCPnbFTeIQ**"> <input type="hidden" name="filetype" value="csv">

      this is the html code... and this is the submit button code...

      <tr> <td><br><input type="submit" value="Download Export File" name="action +_download" id="download" class="btn-primary"></td> </tr>

      Hope this is of some use...

      20080728 Janitored by Corion: Put HTML in code tags, as per Writeup Formatting Tips

        Ok reformatted:

        LOCATION::

        http://website_name/export/download.jsp?t=csv&f=/ccexport/fs076/se1102186454649.csv

        Request headers:
        Host: website_name.com User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1 +6) Gecko/20080702 Firefox/2.0.0.16 Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9 +,text/plain;q=0.8,image/png,*/*;q=0.5 Accept-Language: en-us Accept-Encoding: gzip,deflate Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 Keep-Alive: 300 Connection: keep-alive Referer: http://website_name.com/rnavmap/evaluate.rnav/pidEjc9NdNrtXuC +EdiuJgbZpwf57?activepage=subscriber.activity&action=export&uid=110218 +6454649 Cookie: mbox=PC#1217149956640-344459.05#1280338508|geo#1#1280338508|se +ssion#1217266506140-54222#1217268367|check#true#1217266567|edge#app6- +prod5.prod5.offermatica.com.1217266473358#1217266508; sops=1101500533 +487#1=O#2=A#3=O#4=A#; s_vi=[CS]v1|488C3C0400004D96-A3A096600000468[CE +]; __utmz=152702054.1217149964.1.1.utmccn=(direct)|utmcsr=(direct)|ut +mcmd=(none); cclp_split=sc_01_ts=4501752|sc_01=200806_Award::Recipe B +: You|; cclp_content=lp_uid=20080727_05:12:25.279_8EwuoNSSUMx28IshuRq +sBsz_P1-WS031|; cclp_partner=prt_02_ts=4501918|prt_05_ts=4503694|prt_ +01_ts=4501752|prt_04_ts=4503366|prt_05=partner.name::ROVING|prt_04=pa +rtner.name::ROVING|prt_03_ts=4502980|prt_03=partner.name::ROVING|prt_ +02=partner.name::ROVING|prt_01=partner.name::ROVING|; cclp_referral=p +artner=ROVING|pn=ROVING|sitereferrer=http://website_name.com/login.js +p|partner.name=ROVING|; __utma=152702054.1731584802.1217149964.121724 +6826.1217266509.5; JSESSIONID=0000Ejc9NdNrtXuCEdiuJgbZpwf:-1; BIGipSe +rverProdUI=1227166730.20480.000; BIGipServerProdUICC=1227166730.20480 +.000; BIGipServerProdAOLUI=1227166730.20480.000; BIGipServerProdAOLSS +=1227166730.20480.000; BIGipServerProdUIEA=1227166730.20480.000; pid= +-1; __utmc=152702054; s_cc=true; s_sq=%5B%5BB%5D%5D
Re: Win32::IE::Mechanize download file
by imrags (Monk) on Dec 12, 2008 at 09:12 UTC
    I had done this using Win32::IE::Automation module...
    I have found that module very useful in dealing with IE browser and Windows...

    Raghu