Manual:Pywikibot/Recipes

On this page you will find short snippets of code showing the framework usage by the various bots.

Get language links for all pages
Iterate through wiki pages (possibly with additional filters), and for each page get all listed languagelinks.


 * API

query&generator=allpages&gapfrom=T&prop=langlinks
 * API langlinks limits could make result incomplete for any page without any notification, making batch processing much more difficult - client needs to do more querycontinue calls to know there are no more langlinks for the specific page.


 * Pywikipediabot

Get language links for a set of pages
For a user-supplied list of titles, resolve redirects and get their language links.


 * API

query&prop=langlinks&titles=T|TT&redirects


 * Pywikipediabot

Get non-resolved links and categories for a set of redirected pages
For each page in a set, if redirect, resolve to the redirect target, and get all links and all categories listed. Only link's namespace+title is needed.


 * API

|categories&titles=Archiver|Abstract%20(law)&pllimit=300&redirects query&prop=links|categories&titles=Archiver|Abstract%20(law)&pllimit=300&redirects


 * Pywikipediabot

Page generator -> get links and categories
Same as above, but the pages come from a generator. Received page (not link) might need to be edited.


 * API

|categories query&generator=allpages&gapfrom=T&prop=links|categories


 * Pywikipediabot

Modify a page
Once the bad page is detected, the new text needs to be posted


 * API

[http://en.wikipedia.org/w/api.php?action=edit&summary=...&text=...&token=... edit&summary=...&text=...&token=...]


 * Pywikipediabot