Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
tools:pywikibot [2025/02/09 06:21] – darron | tools:pywikibot [2025/02/11 02:42] (current) – [Examples] darron | ||
---|---|---|---|
Line 1: | Line 1: | ||
====Pywikibot==== | ====Pywikibot==== | ||
+ | Wikimedia automation scripts. | ||
+ | |||
+ | ===Clone=== | ||
- | ===Fetch=== | ||
< | < | ||
git clone --recursive https:// | git clone --recursive https:// | ||
+ | </ | ||
+ | |||
+ | Perform all future operations inside the pywikibot repository directory. | ||
+ | |||
+ | < | ||
cd pywikibot | cd pywikibot | ||
</ | </ | ||
===Install=== | ===Install=== | ||
+ | |||
< | < | ||
python3 -m venv ~/ | python3 -m venv ~/ | ||
Line 14: | Line 22: | ||
</ | </ | ||
- | ===Run=== | + | ===Config=== |
- | Perform this operation inside | + | First create a family file. |
+ | |||
+ | < | ||
+ | ~/ | ||
+ | </ | ||
+ | |||
+ | Enter the URL and name to create a family file for the private site. | ||
+ | Select no when asked about interwiki links. | ||
+ | |||
+ | Eg. | ||
+ | < | ||
+ | from pywikibot import family | ||
+ | |||
+ | class Family(family.Family): | ||
+ | name = ' | ||
+ | langs = { | ||
+ | ' | ||
+ | } | ||
+ | |||
+ | def version(self, | ||
+ | return " | ||
+ | |||
+ | def scriptpath(self, | ||
+ | return { | ||
+ | ' | ||
+ | }[code] | ||
+ | |||
+ | def protocol(self, | ||
+ | return { | ||
+ | ' | ||
+ | }[code] | ||
+ | </ | ||
+ | |||
+ | Next a user configuration is needed. | ||
+ | < | ||
+ | cp user-config.py.sample user-config.py | ||
+ | vi user-config.py | ||
+ | </ | ||
+ | |||
+ | Eg. | ||
+ | < | ||
+ | mylang = ' | ||
+ | family = ' | ||
+ | usernames[' | ||
+ | </ | ||
+ | |||
+ | Lastly run the login script to enter the password. | ||
+ | |||
+ | < | ||
+ | ~/.venvs/pywikibot/bin/python pwb.py login -v -v | ||
+ | </ | ||
+ | |||
+ | ===Examples=== | ||
< | < | ||
Line 22: | Line 82: | ||
</ | </ | ||
+ | < | ||
+ | source ~/ | ||
+ | ./pwb.py welcome.py | ||
+ | deactivate | ||
+ | </ | ||
===Resources==== | ===Resources==== | ||
- | [[https:// | + | [[https:// |
+ | |||
+ | [[https:// | ||
- | [[https://github.com/wikimedia/pywikibot|Pywikibot | + | [[https://www.mediawiki.org/wiki/Manual:Pywikibot/ |
+ | [[https:// | ||