Pywikibot/Setup: Difference between revisions
From charlesreid1
(Created page with "=Setup= ==Install== Start by installing pywikibot. Recommended method is: * git checkout the pywikibot repo * python setup.py build * python setup.py install See Pywikibo...") |
|||
| Line 36: | Line 36: | ||
This will create a Site object corresponding to whichever site you have specified in your user-config.py file. | This will create a Site object corresponding to whichever site you have specified in your user-config.py file. | ||
[[Category:Pywikibot]] | |||
[[Category:Wiki]] | |||
[[Category:Bots]] | |||
[[Category:MediaWiki]] | |||
[[Category:Python]] | |||
[[Category:Charlesreid1.com]] | |||
Revision as of 21:32, 31 January 2018
Setup
Install
Start by installing pywikibot. Recommended method is:
- git checkout the pywikibot repo
- python setup.py build
- python setup.py install
See Pywikibot.
Configure Site
To configure which site you want pywikibot to use, run the provided login script through the pwb.py script. From the pywikibot directory, run:
python3 pwb.py login
This will prompt you for a site URL, username, and password.
(Where do the credentials get stored???)
Once you log in, there will be a user-config.py file created. Copy this to whichever directory you wish to run pywikibot from.
This user-config.py file does not contain any sensitive information.
Write/Run Scripts
Once you have your user config file in your working directory, you can start your script like this:
import pywikibot s = pywikibot.Site()
This will create a Site object corresponding to whichever site you have specified in your user-config.py file.