Manual:Pywikibot/newitem.py

This page is a translated version of the page Manual:Pywikibot/newitem.py and the translation is 25% complete.

newitem.py is a Pywikibot script used to mass create new items on Wikidata based on certain criteria.

  • When was the (Wikipedia) page created?
  • When was the last edit on the page?
  • Does the page contain interwikis?

概念

New articles get created all the time on Wikipedia. With this script you can create new items connected to these articles. The bot looks at the age of the page and the last edit to the article. If both exceed the minimum threshold, the new item will be created. The default thresholds is 21 days for article creation and 7 days since last edit.

構文

The bot expects a generator :

$ python pwb.py newitem <some generator>

You can modify the thresholds. This is the number of days. For example minimum age of 7 days and not edited for 2 days:

$ python pwb.py newitem -pageage:7 -lastedit:2 <some generator>

This script understands various command-line arguments:


パラメーター説明
-lastedit The minimum number of days that has passed since the page was last edited
-pageage The minimum number of days that has passed since the page was created
-touch Do a null edit on every page which has a wikibase item. Be careful, this option can trigger edit rates or captchas if your account is not autoconfirmed


利用できるグローバル引数

以下のオプションを用いることで、user-config.py の設定を上書きすることができます。

グローバル オプション
パラメーター 説明 設定変数名
-dir:パス 既定のディレクトリではなく、PATH で指定されたディレクトリからボットの設定データを読み込みます。  
-config:ファイル The user config filename. Default is user-config.py. user-config.py
-lang:xx user-config.py の設定を上書きする形で、作業するウィキの言語を設定します。xx には設定する適切な言語コードに置き換えてください。 mylang
-family:xyz 作業するウィキのファミリーを設定します。xyz には wikipedia、wiktionary、wikitravel などを指定します。 This will override the configuration in user-config.py. family
-user:xyz 既定の利用者名ではなく、利用者 'xyz' としてログインします。 usernames
-daemonize:xyz 直ちにターミナルへ操作を返し、stdout と stderr をファイル xyz にリダイレクトします。これは stdin からの入力を必要としないボットのみで使用します。  
-help ヘルプ テキストを表示します。  
-log ログファイル (ファイル名は既定で「スクリプト名-bot.log」の形式になります) の出力を有効にします。ログは logs の下位ディレクトリに保存されます。 log
-log:xyz ファイル xyz へのログの出力を有効にします。xyz にはファイル名を指定します。 logfilename
-nolog ログ ファイルの出力を無効にします (既定で有効になっている場合)。  
-maxlag maxlag パラメータの秒数を新しく設定します。 データベース サーバーが遅延している間、ボットの編集を遅らせます。既定値は config.py で設定できます。 maxlag
-putthrottle:n
-pt:n
-put_throttle:n
ページを保存するまでの最小時間(秒)を設定します。 put_throttle
-debug:item
-debug
コンポーネント "item" の拡張デバッグデータをログファイルに出力します。item にはデバッグの対象を指定します。item を指定しない場合、すべてのコンポーネントが対象になります。 debug_log
-verbose
-v
デバッグに役立つ、より詳細なメッセージをコンソールに出力するようにします。 verbose_output
-cosmeticchanges
-cc
config.py あるいは user-config.py での cosmetic_changes 設定を逆にし、無効にします。 その他の設定や制限はそのまま使用されます。 cosmetic_changes
-simulate サーバーへの書き込みを無効にします。 これは、コードのテストやデバッグに有用です (このオプションを使用時、変更される内容は表示されますが、実際に変更されることはありません)。 simulate
-<設定変数>:n 任意の設定変数と数値をオプションとして使用し、それをコマンドラインで変更できるようにします。