Difference between revisions of "Anarchopedia:Bots"

From Anarchopedia
Jump to: navigation, search
(Replacing page with 'nn')
Line 1: Line 1:
''See in French : [[fra:Anarchopedia:Bot|Bot]]''
+
nn
 
+
Bots can automate tasks and perform them much faster than humans. If you have a simple task which you need to perform lots of times (an example might be to add a template to all pages in a category with 1000 pages) then this is a task better suited to a bot than a human.
+
===APIs for bots===
+
In order to make changes to Anarchopedias pages, a bot necessarily has to retrieve pages from Anarchopedia and send edits back.  There are several APIs available for that purpose.
+
 
+
* (api.php). This library was specifically written to permit automated processes such as bots make queries and post changes. Data is available in many different machine-readable formats ([[JSON]], [[XML]], [[YAML]],...). Features have been fully ported from the older Query API interface.
+
*: '''Status:''' Available on all Anarchopedias projects, with a very complete set of queries. The ability to edit pages via API.php enabling bots to operate entirely without screen scraping.
+
 
+
* Screen scraping (index.php). Screen scraping, as mentioned above, involves requesting a Anarchopedia page, looking at the raw HTML code (what you would see if you clicked View->Source in most browsers), and then analyzing the HTML for patterns. There are very few reasons to use this technique anymore and it is mainly used by older bot frameworks written before the API had as many features.
+
*: '''Status:''' Deprecated.
+
 
+
* [[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 Anarchopedias servers.
+
 
+
* Raw (Wikitext) page processing: sending a <code>action=raw</code> or a <code>action=raw&templates=expand</code> GET request to index.php will give the unprocessed wikitext source code of a page.
+
 
+
== Installing Pywikipediabot ==
+
 
+
In short, make a subdirectory inside of your working directory and go there:
+
 
+
<source lang="bash">
+
$ mkdir mybot
+
$ cd mybot
+
</source>
+
 
+
Invoke Subversion checkout to download pywikipediabot:
+
 
+
<source lang="bash">
+
$ svn checkout http://svn.wikimedia.org/svnroot/pywikipedia/trunk/pywikipedia/ pywikipedia
+
</source>
+
 
+
Pywikipediabot is a very active project. Because of that you should periodically (maybe daily, maybe weekly) update your copy:
+
 
+
<source lang="bash">
+
$ cd pywikipedia/
+
$ svn update
+
</source>
+
 
+
== Logging in ==
+
 
+
Your bot should be logged in to the particular project.
+
Go into the directory "pywikipedia":
+
 
+
<source lang="bash">
+
$ cd pywikipedia/
+
</source>
+
 
+
Make file "user-config.py" by using your favorite editor. It should contain something like:
+
 
+
<source lang="python">
+
mylang = 'en'
+
family = 'anarchopedia'
+
usernames['anarchopedia']['en'] = 'My Bot Name'
+
usernames['anarchopedia']['pl'] = 'My Bot Name'
+
usernames['anarchopedia']['sr'] = 'My Bot Name II' # you may use different names
+
</source>
+
 
+
By invoking "login.py" program...
+
 
+
<source lang="bash">
+
$ python login.py
+
</source>
+
 
+
... you will get a prompt for inserting your password...
+
 
+
<pre>
+
Checked for running processes. 1 processes currently running, including the current process.
+
Password for user My Bot Name on wikinews:en:
+
</pre>
+
 
+
... and, if everything is good, program will give to you a message like:
+
 
+
<pre>
+
Logging in to anarchopedia:en as My Bot Name
+
Should be logged in now
+
</pre>
+
 
+
However, if you have more then one account (like it was described) and you have one password for all bots (which is little bit less safe, but much more practical), you should use options "-all" and "-pass":
+
 
+
<pre>
+
python login.py -all -pass
+
Checked for running processes. 1 processes currently running, including the current process.
+
Password for all accounts:
+
Logging in to anarchopedia:sr as My Bot Name II
+
Should be logged in now
+
Logging in to anarchopedia:en as My Bot Name
+
Should be logged in now
+
Logging in to anarchopedia:pl as My Bot Name
+
Should be logged in now
+
</pre>
+
 
+
== Invoking Python ==
+
 
+
You may invoke scripts by typing "python" before them:
+
 
+
<source lang="bash">
+
$ python mybot.py
+
</source>
+
 
+
==Scripts==
+
Here is a list of the existing bots with links to their descriptions:
+
{| cellspacing="0" cellpadding="0" border="0" width="100%"
+
|- align="left" valign="middle"
+
| style="width:1ex" | &nbsp;
+
!Main bot scripts
+
| style="width:4ex" | &nbsp;
+
!Other bot scripts
+
| style="width:2ex" | &nbsp;
+
|-
+
| ||
+
----
+
| ||
+
----
+
| ||
+
----
+
|- align="left" valign="top"
+
| ||
+
* [[category.py]] Script which manages categories
+
* [[imagetransfer.py]] Copy images to another wiki
+
* [[interwiki.py]] Creates Interlanguage links between a project
+
* [[redirect.py]] Fixes double redirects, and  deletes broken redirects
+
* [[replace.py]]  Replaces text
+
* [[solve_disambiguation.py]]
+
* [[table2wiki.py]] Converts HTML-tables to MediaWiki's language
+
* [[template.py]] Replaces a template with another
+
* [[upload.py]] Upload images to wiki
+
* [[weblinkchecker.py]] finds broken external links
+
'''Auxiliary programs'''
+
* [[login.py]] Essential python program
+
| ||
+
* [[catall.py]] Adds or changes categories
+
* [[copyright.py]] Checks copyright text in search engines
+
* [[delete.py]] deletes pages en masse
+
* [[delinker.py]] Bot delinks and replaces images
+
* [[imageharvest.py]] Copies multiple images to a wiki
+
* [[movepages.py]] Moves page to another title
+
* [[pagefromfile.py]] Create pages from a textfile
+
* [[protect.py]]
+
* [[standardize_interwiki.py]] Moves the interwiki links
+
* [[standardize_notes.py]] Improves references and citations
+
* [[test.py]] Outputs logged-in account and wikifamily.
+
* [[warnfile.py]]
+
* [[welcome.py]] Used to welcome new users
+
* [[version.py]] Outputs about Pywikipedia's revision number and so on
+
|}
+
 
+
 
+
[[Category:Anarchopedia documentation]]
+

Revision as of 09:49, 20 November 2008

nn