Sabalon has asked for the wisdom of the Perl Monks concerning the following question:
I am trying to get at some data inside a MediaWiki uh..wiki. I am wanting to make use of the render for print function of index.php to grab out some info and display it elsewhere.
That is why I am not using the MediaWiki::API calls...no way to have it formatted for you, templates, etc...
The HTML that comes back from my LWP User Agent keeps saying TheWiki uses cookies to login in users. You have cookies disabled. Please enable them and try again. LIES! :)
The response is 200, but the data it returns when I dump it out is the same login page with the cookie message.use HTTP::Request; use HTTP::Request::Common qw(GET POST); use HTTP::Cookies; use LWP::UserAgent; my $browser=new LWP::UserAgent; my $cookies=new HTTP::Cookies( file=>"/tmp/cookies.txt", autosave=>1, +ignore_discard=>1); $browser->cookie_jar($cookies); $req = POST 'http://localhost/wiki/index.php?title=Special:Userlogin&a +ction=submitlogin&wpName=readuser&wpPassword=letmein'; $response=$browser->request($req);
If I remove the cookie file before running this, it recreates it, and it does put a cookie in there for the session (however I had to add ignore_discard to get it to do that.)
I have tried several variations - GET vs POST, putting the post variables as content to the request. I tried the mwpush.pl shown here: http://en.wikipedia.org/wiki/User:KeithTyler/mwpush.pl but it fails in the same way (in fact most of my code is ripped from that example since mine wasn't working)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: LWP UserAgent to script Mediawiki reads
by Anonymous Monk on Feb 02, 2012 at 04:40 UTC | |
by Sabalon (Initiate) on Feb 02, 2012 at 14:40 UTC | |
|
Re: LWP UserAgent to script Mediawiki reads
by Khen1950fx (Canon) on Feb 02, 2012 at 05:58 UTC | |
by Anonymous Monk on Feb 02, 2012 at 16:21 UTC | |
|
Re: LWP UserAgent to script Mediawiki reads
by Anonymous Monk on Feb 02, 2012 at 04:34 UTC | |
by Sabalon (Initiate) on Feb 02, 2012 at 14:43 UTC | |
|
Re: LWP UserAgent to script Mediawiki reads
by PikMaster (Initiate) on Oct 30, 2012 at 14:25 UTC | |
by PikMaster (Initiate) on Oct 30, 2012 at 14:31 UTC |