Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Re: problem web xml file

by dasgar (Curate)
on Jul 01, 2012 at 20:56 UTC ( #979325=note: print w/ replies, xml ) Need Help??

in reply to problem web xml file

When I tried running your one-liner, I was definitely seeing some strange ASCII characters.

I can't give you an explanation of what's happening or why there's a difference in outcome, but the code below seemed to download the file with no problems.

use strict; use warnings; use LWP::Simple; my $fh; my $file = "test.xml"; my $url = ' +F998&part=items'; open($fh,">",$file) or die "Unable to open file '$file': $!"; my $data = get($url); print $fh $data; close($fh);

Comment on Re: problem web xml file
Download Code
Re^2: problem web xml file
by Anonymous Monk on Jul 01, 2012 at 21:11 UTC


    Learn to HTTP people, its not hard :)

    $ lwp-request -UuSsEed " +521366R0REA16F998&part=items GET +rt=items User-Agent: lwp-request/6.03 libwww-perl/6.04
    200 OK
    Connection: close
    Date: Sun, 01 Jul 2012 21:06:29 GMT
    Server: Apache/2.2.12 (Ubuntu)
    Content-Encoding: gzip
    Content-Length: 666
    Content-Type: application/xml; charset=UTF-8
    Client-Date: Sun, 01 Jul 2012 21:07:21 GMT
    Client-Response-Num: 1
    X-Compression: gzip
    X-Powered-By: PHP/5.2.10-2ubuntu6.4

      Ahh its compressed! So how would I uncompress it to print to STDOUT?

      I just really need to read and save the file so it should work now but would like to know how to deal with on cmdline.

        My shell doesn't interpolate $ua  perl -CSDL -MLWP::Simple=$ua -e " print $ua->get( shift )->decoded_content "

        It's compressed, but it correctly includes a Content-Encoding HTTP header, so LWP::Simple should be decompressing it for you. (My copy certainly does.)

        perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://979325]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (12)
As of 2015-05-29 17:13 GMT
Find Nodes?
    Voting Booth?

    In my home, the TV remote control is ...

    Results (590 votes), past polls