Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

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('http://192.168.1.1'); 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( 'http://192.168.1.1/wiki/index.php?title= Special:Userlogin&action=submitlogin&wpName= readuser&wpPassword=letmein', $base); my $res = $ua->request($req); print $res->as_string;


Comment on Re: LWP UserAgent to script Mediawiki reads
Download Code
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?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://951363]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (11)
As of 2014-09-16 20:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (46 votes), past polls