Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

Re: LWP UserAgent to script Mediawiki reads

by Khen1950fx (Canon)
on Feb 02, 2012 at 05:58 UTC ( #951363=note: print w/replies, xml ) Need Help??

in reply to LWP UserAgent to script Mediawiki reads

How about something like this?
#!/usr/bin/perl -l use strict; use warnings; $| = 1; require IO::Socket; my $D = shift || ''; if ($D eq 'daemon') { require HTTP::Daemon; my $d = HTTP::Daemon->new(Timeout => 10); print "Pleased to meet you at: <URL:", $d->url, ">\n"; open STDOUT, '>', '/dev/null'; while (my $c = $d->accept) { my $r = $c->get_request; if ($r) { my $p = ($r->uri->path_segments)[1]; my $func = lc("httpd_" . $r->method . "_$p"); if (defined &$func) { &$func($c, $r); } else { $c->send_error(404); } } $c = undef; } print STDERR "HTTP Server terminated\n"; exit; } require URI; my $base = URI->new(''); sub url { my $u = URI->new(@_); $u = $u->abs($_[1]) if @_ > 1; $u->as_string; } print "\tWill access HTTP server at $base"; require LWP::UserAgent; require HTTP::Request; require HTTP::Cookies; my $ua = new LWP::UserAgent; $ua->agent("Mozilla/0.01 " . $ua->agent); my $cookies = new HTTP::Cookies( file => '/tmp/cookies.txt', autosave => 1, ignore_discard => 1, ); $ua->cookie_jar($cookies); my $req = new HTTP::Request POST => url( ' Special:Userlogin&action=submitlogin&wpName= readuser&wpPassword=letmein', $base); my $res = $ua->request($req); print $res->as_string;

Replies are listed 'Best First'.
Re^2: LWP UserAgent to script Mediawiki reads
by Anonymous Monk on Feb 02, 2012 at 16:21 UTC

    And what is that supposed to be?

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://951363]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (7)
As of 2018-07-23 17:35 GMT
Find Nodes?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?

    Results (472 votes). Check out past polls.