Hello all. I had a full head of hair before starting this. Now I feel like Kojack!

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! :)

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);
The response is 200, but the data it returns when I dump it out is the same login page with the cookie message.

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)


In reply to LWP UserAgent to script Mediawiki reads by Sabalon

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.