MediaW...t::page(3pm)

πŸ“¦
version 0.2.2 Β· 2 versions
  • 0.2.2 Β· debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking (latest)
  • 0.2.2 Β· ubuntu jammy
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– 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, or undef if 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, or undef if the editor was anonymous. anon editors stay mysterious πŸ™ˆ
  • $page->userid β€” returns a number that's the id for the user that $page->username gives you back, or undef if the editor was anonymous. matching set, cute πŸŽ€
  • $page->userip β€” returns a string of the IP of the editor if the edit was anonymous, or undef otherwise. so if it's anon, you get the address; if not, nothing, nada, undef πŸ’€
  • $page->minor β€” returns 1 if this article was flagged as a minor edit, otherwise returns 0. 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