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

Hey, monks! This is probably an easy question for you guys, but I haven't unearthed the answer on CPAN yet.

I'm looking for a Perl module to do the same thing as Python's urllib module -- which will attach character encode query string parameters to a URL to form a complete HTTP GET request. Most importantly, urllib returns the response.

Perl may have several options. If you can mention a few, I would greatly appreciate it.

Thanks!

  • Comment on Perl equivalent to Python's urllib module?

Replies are listed 'Best First'.
Re: Perl equivalent to Python's urllib module?
by Corion (Patriarch) on Jul 07, 2012 at 20:07 UTC

    The closest in functionality to urllib would be LWP::UserAgent and/or LWP::Simple, as they can open a variety of URLs.

    Depending on what you want to achieve, maybe WWW::Mechanize fits your needs better, if you want to automate a web application.

Re: Perl equivalent to Python's urllib module?
by tobyink (Canon) on Jul 07, 2012 at 20:44 UTC

    How about this?

    use Web::Magic; print Web::Magic -> new('http://www.perlmonks.org/', node_id => 980503) -> querySelector('div.doctext') -> toString;
    perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'