Beefy Boxes and Bandwidth Generously Provided by pair Networks DiBona
Perl: the Markov chain saw
 
PerlMonks  

Download excel from website and save it to disk

by kalyanrajsista (Scribe)
on Jun 01, 2010 at 08:28 UTC ( #842535=perlquestion: print w/ replies, xml ) Need Help??
kalyanrajsista has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks

I'm trying to download an excel file from a website using WWW::Mechanize module, but downloaded file is of binary format. How can I get the actual content of Excel file and save it to the disk.

use strict; use WWW::Mechanize; my $browser = WWW::Mechanize->new(); my $xlurl = "http://some.site.com/InfoCenter/Documents/COPY%20OF%20KIN +%2014DAYS%20%20%2001%20%20JUNE%20%20%202010.xls"; my $xls = $browser->get($xlurl); my $xlcontent=$xls->as_string();

Comment on Download excel from website and save it to disk
Download Code
Re: Download excel from website and save it to disk
by Gangabass (Priest) on Jun 01, 2010 at 08:48 UTC
Re: Download excel from website and save it to disk
by Corion (Pope) on Jun 01, 2010 at 08:56 UTC
      my $xlcontent

      above variable contain excel data in Binary format which is not actually stored anywhere in my disk, so I can't use any of the Module to read the excel data.

      I'm looking for saving the excel file on the disk and process it afterward.

        Yes. For saving, read up about binmode and print. For processing the data, read up about the modules I already linked to. You will need to do some reading and then some programming.

        Also, your assignment to $xlcontent does propably not do what you want. You want maybe

        $browser->save_content
        or
        my $xlcontent = $browser->content;

        Read WWW::Mechanize in addition to the other module documentation.

Re: Download excel from website and save it to disk
by sierpinski (Hermit) on Jun 01, 2010 at 12:13 UTC
    Do you have wget available? It's purpose is to retrieve files via http/https.

    You could call it with the usual backticks, exec, or system calls. Detailed documentation for it can be found here.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://842535]
Approved by marto
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (7)
As of 2014-04-21 03:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (490 votes), past polls