in reply to Re: Exporting Curl content to html
in thread Exporting Curl content to html

Did the author run it on Unix ?. I'm guessing the line $json =~ /^.+\r\n\r\n:?(.+)$/s; is removing the header but on windows should be \n\n. However, if you remove the -i the curl download doesn't include the header. Using -o you can write the result to a file.

Try this revised script (untested).

#!perl use strict; my $base_url= 'https://'; my $user = ''; my $pass = ''; my $out_dir = 'pages'; my $format = 'html'; my $out= `curl -u $user:$pass -i $base_url/file/root/tree?format=ids`; if ($out =~ /.+\s*([\d,]+)$/){ my @ids = split /,/, $1; foreach my $id (@ids) { print "$id\n"; my $cmd = "curl -u $user:$pass $base_url/files/$id/contents?format +=$format -o $out_dir/$id.$format"; my $status = system($cmd); if ($status) { die "system error: $?" } } } else { print "Error - No ids found"; }
poj