Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ruby-on-rails-3/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mediawiki机器人以查找最近几个小时的更改_Mediawiki - Fatal编程技术网

Mediawiki机器人以查找最近几个小时的更改

Mediawiki机器人以查找最近几个小时的更改,mediawiki,Mediawiki,请求: 我想使用一个机器人(mediawiki api或直接数据库访问),它可以找出过去几个小时所有页面的变化。我需要一个diff,然后想处理文本。猜测正确的方向(上次编辑的差异)就足够了。我知道如何迭代页面 背景: 我想处理diff以找到新的下载链接,作为模板调用的一部分。对于这一步,我不需要帮助。您可以使用,这应该是一个(也许)好的开始: from pywikibot import Site from datetime import timedelta my_site = Site(lan

请求:

我想使用一个机器人(mediawiki api或直接数据库访问),它可以找出过去几个小时所有页面的变化。我需要一个diff,然后想处理文本。猜测正确的方向(上次编辑的差异)就足够了。我知道如何迭代页面

背景:

我想处理diff以找到新的下载链接,作为模板调用的一部分。对于这一步,我不需要帮助。

您可以使用,这应该是一个(也许)好的开始:

from pywikibot import Site
from datetime import timedelta

my_site = Site(language, family) # Or set default site with pywikibot config file

# From this object you may get the changes by timestamp, pywikibot.Timestamp are datetime objects as well.
current_time = my_site.getcurrenttime()
my_site.recentchanges(start = current_time, end=current_time - timedelta(hours=6))
您可以迭代在过去X(6)小时内更改的页面,并针对每个页面:

from pywikibot import Page

current_page = Page(my_site, page_title)  # Page title written in the recentchanges 
return object
revisions = current_page.revisions(total=some_number, content=True)
之后,您可以使用一些内部api来获得两个版本之间的差异:

from pywikibot.diff import PatchManager

PatchManager(first_rev_text, second_rev_text).print_hunks()  # print_hunks is for interactive changes, but you can work with any internals api here (that might not be simple).
这并不是你所需要的全部代码,但你可以从这里开始工作,添加更多的逻辑来解决你的问题, 祝你好运:)

你可以使用,这应该是一个(也许)好的开始:

from pywikibot import Site
from datetime import timedelta

my_site = Site(language, family) # Or set default site with pywikibot config file

# From this object you may get the changes by timestamp, pywikibot.Timestamp are datetime objects as well.
current_time = my_site.getcurrenttime()
my_site.recentchanges(start = current_time, end=current_time - timedelta(hours=6))
您可以迭代在过去X(6)小时内更改的页面,并针对每个页面:

from pywikibot import Page

current_page = Page(my_site, page_title)  # Page title written in the recentchanges 
return object
revisions = current_page.revisions(total=some_number, content=True)
之后,您可以使用一些内部api来获得两个版本之间的差异:

from pywikibot.diff import PatchManager

PatchManager(first_rev_text, second_rev_text).print_hunks()  # print_hunks is for interactive changes, but you can work with any internals api here (that might not be simple).
这并不是你所需要的全部代码,但你可以从这里开始工作,添加更多的逻辑来解决你的问题, 祝你好运:)