手册:Pywikibot/兼容/基本使用

This page is a translated version of the page Manual:Pywikibot/Compat/Basic use and the translation is 71% complete.
Outdated translations are marked like this.

使用

对于Windows用户,请参阅创建快捷方式

选择并运行机器人脚本

现在您已经安装了python和Pywikibot,您需要获得操作系统的文本界面。

访问pywikibot

创建名为user-config.py 的文件后,您可以访问pywikibot。

Windows这是通过打开开始菜单,然后点击'运行'来完成的。系统会要求您提供程序名称,键入“cmd.exe”。

  • 键入chdir C:\来将根目录更改为C:
  • Type chdir \"name of the folder where pywikibot has been downloaded" (For example: chdir \"pywikibot" if the file is in the C: folder.)

可能需要执行以下步骤:

  • 将子文件夹externals中的文件夹httplib2向上移动一级。
  • All scripts that you would like to use need to be copied from the scripts subfolder to the main folder. This includes login.py.

Mac上,在/Applications/Utilities中找到Terminal.app,参见Mac安装

On Linux or any other Unix, use any terminal application such as gnome-terminal, konsole, xterm, or simply the text-mode console.

In compat, run the script login.py by typing "python login.py". If you don't have user-config.py yet, this command will interactively create it.

In core, from the core directory, run the script login.py by typing "python pwb.py login". If you don't have user-config.py yet, this command will interactively create it.

pwb.py does add the core directory to the `PATH` variable so that python sees the pywikibot directory. There are other ways to fix this like adding the core directory (or any directory containing the pywikibot directory) to `PATH` or `PYTHONPATH`.
输入密码

Python将返回:

Password for user your_bot on your_site:en:

Use the password you used for the bot's login name. Note that your input will not be visible for privacy reasons. The bot can't work anonymously. Unless you change your password, you normally need to run this program only once, the bot usually does not get logged off.

使用机器人

机器人在下载时位于pywikibot主文件夹中。

如有必要,使用命令cd转到保存机器人文件的目录。

现在通过键入"python botname.py"来运行任何机器人(如果您使用的是Windows,则可以省略“python”)。

脚本

首页: Manual:Pywikibot/脚本

命令行参数

虽然许多bot脚本都有自己的命令行参数,在各自的页面(或源代码中)记录,但除非另有说明,否则所有机器人都会识别以下命令行参数:

(完整列表:手册:Pywikibot/全域选项

-help
输出全域机器人参数列表(此列表),然后是特定机器人的帮助(如果可用)。
-lang:xx
将语言代码xx设置为要处理的Wiki的语言,覆盖user-config.py中的配置。
-family:xyz
Set the family of the wiki you want to work on, e.g., wikipedia, wiktionary, wikitravel, ... This will override the configuration in user-config.py.
-user:xyz
以用户'xyz'而不是默认用户名登录。
-log
启用日志文件。日志将存储在logs子目录中。
-log:xyz
启用xyz作为文件名的日志文件。
-nolog
禁用日志文件(如果默认启用)。
-putthrottle:nn
Set the minimum time (in seconds) the bot will wait between saving pages. The default value is 10.

For example, python scriptname.py -family:wiktionary will run the "scriptname" bot on wiktionary articles, overriding the default family setting in your user configuration.

维基媒体计划上的权限

Make sure that your bot is approved by the wiki community where you are going to use it: see the global Bot policy for guidance. Strictness differs greatly between various projects.

使用普通浏览器,为机器人创建登录名和密码。最好使用一个明确表示它是机器人的名称,最好也表示运行它的人。 一种常见的方法是使用您自己的登录名并在其中添加“bot”一词,但也存在其他几种形式。