Content deleted Content added
Troutfarm27 (talk | contribs) m Reverted edit by 12.138.73.146 (talk) to last version by --WikiUser1234945-- |
→Logging in: de-emphasize re-inventing the wheel |
||
(22 intermediate revisions by 16 users not shown) | |||
Line 42:
* [[Special:Export]] can be used to obtain bulk export of page content in XML form. See [[mw:Manual:Parameters to Special:Export|Manual:Parameters to Special:Export]] for arguments;
*: '''Status:''' Built-in feature of MediaWiki, available on all Wikimedia servers.
* Raw (Wikitext) page processing: sending
*:'''Status:''' Built-in feature of MediaWiki, available on all Wikimedia servers.
Line 48:
===Logging in===
Approved bots need to be logged in to make edits. Although a bot can make read requests without logging in, bots that have completed testing should log in for all activities. Bots logged in from an account with the bot flag can obtain more results per query from the MediaWiki API (api.php).
Use of a bot framework is recommended as they handle login and cookies. Common frameworks include [[mw:Manual:Pywikibot|pywikibot]] for Python and [[mw:Manual:Mwn|mwn]] for Node.js. The manual steps below can be followed if you are implementing your own framework.
To log a bot in using the [[mw:API|MediaWiki API]], two requests are needed:
Line 93:
Edit conflicts occur when multiple, overlapping edit attempts are made on the same page. Almost every bot ''will'' eventually get caught in an edit conflict of one sort or another, and should include some mechanism to test for and accommodate these issues.
Bots that use the Mediawiki API (api.php) should retrieve the edit token, along with the <code>starttimestamp</code> and the last revision "base" timestamp, ''before'' loading the page text in preparation for the edit; <code>prop=info|revisions</code> can be used to retrieve both the token and page contents in one query (<span class="plainlinks">[https://en.wikipedia.org/w/api.php?action=query&titles=Wikipedia:Sandbox&prop=info|revisions&inprop=&intoken=edit&rvprop=timestamp|content example]</span>). When submitting the edit, set the <code>starttimestamp</code> and <code>basetimestamp</code> attributes, and check the server responses for indications of errors. For more details, see [[mw:API:Edit|MediaWiki:API:Edit - Create
Generally speaking, if an edit fails to complete the bot should check the page again before trying to make a new edit, to make sure the edit is still appropriate. Further, if a bot rechecks a page to resubmit a change, it should be careful to avoid any behavior that could lead to an infinite loop and any behavior that could even resemble [[WP:EW|edit warring]].
Line 103:
====Idea====
* The first task in creating a Wikipedia bot is extracting the requirements or coming up with an idea. If you don't have an idea of what to write a bot for, you could pick up ideas at [[Wikipedia:Bot requests|requests for work to be done by a bot]].
* Make sure an existing bot isn't already doing what you think your bot should do. To see what tasks are already being performed by a bot, see [[Wikipedia:
====Specification====
Line 113:
====Software architecture====
* Think about '''how''' you might create
====Implementation====
Line 162:
====Bot Flag====
A bot's edits will be visible at [[Special:RecentChanges]], unless the edits are set to indicate a bot. Once the bot has been approved and given its bot flag permission, one can add
====Monitoring the bot status====
Line 215:
==== MATLAB ====
* [https://github.com/JRCSTU/MatWiki MatWiki] – a preliminary (as of Feb 2019) MATLAB R2016b(9.1.x) client supporting just bot-logins
====Microsoft .NET====
Line 261:
==== Lua ====
* During the Lua Annual Workshop 2016, {{U|Jim Carter}} and {{U|Dfavro}} started developing Lua's bot framework for Wikimedia projects. Please contact Jim Carter on their talk page to discuss
* [https://github.com/AlexanderMisel/mwtest mwtest] is an example using Lua to write a wikibot, created by [[User:Alexander Misel]], with simple API.
|