Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Getting more out of LWP::Simple

by Dog and Pony (Priest)
on May 23, 2002 at 07:15 UTC ( #168684=perltutorial: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    # Note that if you do this, you must explicitly
    # export everything you want to use:
    ...
    $ua->timeout(30);
    
    my $html = get $webpage || die "Timed out!";
    
  2. or download this
    $ua->agent('My agent/1.0');
    
  3. or download this
    use LWP::Simple qw($ua get);
    use HTTP::Cookies;
    ...
    get $webpage . $login_string;
    
    my $logged_in_page = get $webpage . $private_page;
    
  4. or download this
    use LWP::UserAgent;
    
    ...
    $response = $ua->request($request);
    
    my $html = $response->content;
    
  5. or download this
    perl -MLWP::Simple -e "getprint 'http://perlmonks.org?node_id=145587'"
    
    perl -MLWP::Simple -e "getprint 'http://perlmonks.org?node=showchatmes
    +sages&displaytype=raw'"
    
  6. or download this
    perl -MLWP::Simple -e "get 'http://perlmonks.org?op=login&user=Dog and
    + Pony&passwd=doNotUseThisPW&op=message&message=Hi it is me on the com
    +mand line!'"
    
  7. or download this
    my $words = 'LWP::Simple tutorial'
    my $html = get "http://www.perlmonks.org/index.pl?node=$words";
    
  8. or download this
    my $response_code = mirror $webpage, 'webpage.html';
    
    die "Bad response $response_code" unless is_success($response_code);
    
  9. or download this
    use LWP::Simple;
    
    print "$webpage exists and server is up!\n" if (head($webpage));
    
  10. or download this
    my @headers = head $webpage;
    
    print join "\n", @headers;
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perltutorial [id://168684]
help
Chatterbox?
[Your Mother]: Module::Install
[Your Mother]: :P
[LanX]: Moma knows best! ;-)
[Your Mother]: I am quite aware that Module::Build is MUCH more in favor with many monks but I had trouble with it every time I tried to use it and trouble with CPAN stuff that used it too.
[Your Mother]: Take my advice with a grain of salt. I haven't done a new CPAN release in years at this point.
[LanX]: I want to author a new module for CPAN w/o complicated build structure
[LanX]: ther is also Dist::Zilla :-/
[LanX]: How to make a CPAN Module Distribution from 2002
[Your Mother]: Dist::Zilla is kind of the nuclear option. I set it up back in the day but it's really targeted at authors who are managing MANY modules and want to automate everything.
[erix]: perlancar should know ;)

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (9)
As of 2017-08-18 17:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Who is your favorite scientist and why?



























    Results (306 votes). Check out past polls.

    Notices?