MediaWiki API 具有编辑功能,可在 pywikibot 中使用。根据https://doc.wikimedia.org/pywikibot/master/api_ref/pywikibot.site.html
使用页面参数调用该函数:
editpage(page, summary=None, minor=True, notminor=False, bot=True, recreate=True, createonly=False, nocreate=False, watch=None, **kwargs)[source]¶
页面需要构建源。我找不到一个例子。
只有一行作为接受的答案,并且不使用站点或页面。我很困惑。
使用 python 代码直接使用 pyWikiBot 创建和或编辑页面的正确方法是什么?(不是脚本...)
https://github.com/wikimedia/pywikibot/blob/master/pywikibot/page/init .py# L2328
有构造函数:
"""Page: A MediaWiki page."""
@deprecated_args(defaultNamespace='ns', insite=None)
def __init__(self, source, title='', ns=0):
"""Instantiate a Page object."""
if isinstance(source, pywikibot.site.BaseSite):
if not title:
raise ValueError('Title must be specified and not empty '
'if source is a Site.')
super(Page, self).__init__(source, title, ns)
不幸的是,它没有正确记录,并且是包含所有类的 6000 行init .py 文件的一部分。
尝试的时候
newPage=Page(site,pageTitle)
newPage.text=pageContent
我明白了
AttributeError: APISite instance has no attribute 'edit'
site.edit(newPage,'summary')