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

How do I save the result of GET to a file?

update (broquaint): title change (was get form)

  • Comment on How to save the result of a http request in a file

Replies are listed 'Best First'.
Re: How to save the result of a http request in a file
by Corion (Patriarch) on Aug 04, 2003 at 11:10 UTC

    To expand a bit on the solution by cianoz:

    You need the LWP module installed, and also the tools that LWP offers to install. The GET programm is not much more than the following Perl oneliner:

    # for Windows perl -MLWP::Simple -e "getprint 'http://www.example.com/'" # for Unix perl -MLWP::Simple -e 'getprint q(http://www.example.com/)'

    You can also directly store the result in a file using the mirror command of LWP::Simple:

    perl -MLWP::Simple -e 'mirror q(http://www.example.com),"example-store +d-page.html"'

    Looking back at your previous posts, please think about how you can make your node titles a bit more descriptive. For example, for this node, a title like How to save the result of a http request in a file might have been more descriptive.

    perl -MHTTP::Daemon -MHTTP::Response -MLWP::Simple -e ' ; # The $d = new HTTP::Daemon and fork and getprint $d->url and exit;#spider ($c = $d->accept())->get_request(); $c->send_response( new #in the HTTP::Response(200,$_,$_,qq(Just another Perl hacker\n))); ' # web
Re: How to save the result of a http request in a file
by cianoz (Friar) on Aug 04, 2003 at 11:05 UTC
    GET http://url > file.html
Re: How to save the result of a http request in a file
by Abigail-II (Bishop) on Aug 04, 2003 at 11:07 UTC
    $ GET http://www.example.com > file_name

    Abigail