MediaW...t::page(3pm)
π MediaWiki::DumpFile::page β the manual, but make it make sense π
okay bestie, sit down, we're learning MediaWiki::DumpFile::page, part of the User Contributed Perl Documentation situation (perl manual, section 3pm, iykyk). This is the whole vibe. π¦
β¨ NAME β¨
Parse::MediaWikiDump::page β the object that represents one specific revision of a MediaWiki page. that's it, that's the job, and it eats every time π
πΈ ABOUT πΈ
so, plot twist: you don't really make these yourself. this object gets handed to you by the next method of Parse::MediaWikiDump::Pages and Parse::MediaWikiDump::Revisions. literally it just appears in your life like a little gift π
like, you could construct instances of this particular object on your own, but the main character move is using it to read out information about a page that lives in a MediaWiki instance. that's the whole point. that's the assignment. π
π SYNOPSIS π
use MediaWiki::DumpFile::Compat;
$pages = Parse::MediaWikiDump::Pages->new('pages-articles.xml');
#get all the records from the dump files, one record at a time
while(defined($page = $pages->next)) {
print "title '", $page->title, "' id ", $page->id, "\n";
}
not me reading a whole XML dump one record at a time like it's a group chat I'm catching up on π iconic behaviour honestly
π METHODS π
okay this is the good part. every method, every detail, no skips, fr fr.
$page->redirectβ returns an empty string (something like'') for the main namespace, or a string holding the name of the namespace. so like, if it's giving redirect energy, you'll know π«Ά$page->categoriesβ hands you a reference to an array stuffed with a list of categories, orundefif there are literally no categories. β οΈ big caveat bestie: this method does not understand templates, so it may not return every category the article actually belongs to. it's doing its best, but it's not omniscient, lowkey.$page->titleβ returns a string of the full article title, and yes that includes the namespace if one's present. full government name energy π§$page->namespaceβ returns a string of the article's namespace, or an empty string if the article is chilling in the default namespace. no namespace, no problem π$page->idβ returns a number, and that number is the id for the page inside the MediaWiki instance. her ID, if you will πͺͺ$page->revision_idβ returns a number, and that number is the revision id for the page in the MediaWiki instance. different number, different lore β¨$page->timestampβ returns a string looking exactly like this:2005-07-09T18:41:10Z. that format, no deviations, periodt β°$page->usernameβ returns a string of the username responsible for this specific revision of the article, orundefif the editor was anonymous. anon editors stay mysterious π$page->useridβ returns a number that's the id for the user that$page->usernamegives you back, orundefif the editor was anonymous. matching set, cute π$page->useripβ returns a string of the IP of the editor if the edit was anonymous, orundefotherwise. so if it's anon, you get the address; if not, nothing, nada,undefπ$page->minorβ returns1if this article was flagged as a minor edit, otherwise returns0. binary. decisive. slay β$page->textβ returns a reference to a string that contains the article title text. yes, a reference to a string, we said what we said π₯
π a lil sign-off π
and that's the whole page, bestie β this doc is from the User Contributed Perl Documentation, MediaWiki::DumpFile::page(3pm), version perl v5.34.0, dated 2022-06-15. go forth and parse your dumps, you absolute legend ππβ¨
π¦ where this page comes from
- debian bookworm: libmediawiki-dumpfile-perl 0.2.2-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libmediawiki-dumpfile-perl 0.2.2-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libmediawiki-dumpfile-perl 0.2.2-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libmediawiki-dumpfile-perl 0.2.2-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libmediawiki-dumpfile-perl 0.2.2-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms