curl2lwp - convert Curl command line arguments to LWP / Mechanize Perl code
After inspiration by a comment on Perlmonks.org and some slight hacking,
I'm very proud to announce HTTP::Request::FromCurl, together
with its companion online site at https://corion.net/curl2lwp.psgi. The
module and included curl2lwp
program allow you to easily convert
curl
command lines to Perl code that uses LWP::UserAgent
resp. WWW::Mechanize.
Some code:
curl2lwp.pl -X GET -A xpcurl/1.0 https://perlmonks.org/
outputs the following code:
my $ua = WWW::Mechanize->new(); my $r = HTTP::Request->new( 'GET' => 'https://perlmonks.org/', [ 'Accept' => '*/*', 'Host' => 'perlmonks.org:443', 'User-Agent' => 'curl/1.0', ], ); my $res = $ua->request( $r, );
The online version creates a bit more code, as the output there is likely not consumed by advanced Perl programmers.
The module parses a subset of the valid
The app driving the online interface is not yet released onto CPAN, but as it is mostly HTML scaffolding and some Javascript, it should be released fairly soon.
Leave a comment