如何列出从特定 IP 地址对维基百科所做的所有匿名(因此 IP-public)编辑?

How to list all anonymous (so IP-public) edits made to Wikipedia from a specific IP address?

假设我有一个 IP 地址,例如 IP address of the Hungarian Parliament193.224.28.151

如何获取使用此 IP 地址进行的所有维基百科编辑的列表?

a Tom Scott webpage,我读到:

Here's a fact: Wikipedia stores the IP addresses of anonymous users.

Here's another fact: all of the web traffic from the Houses of Parliament is sent through one of two proxy servers — which means that every anonymous edit to Wikipedia from within Parliament is attributed to one of just two IP addresses.

I'm sure you can see where this is going.

我还没有找到这个项目的存储库。如果可以在浏览器中或使用 Python 完成,那就太好了。

您可以使用 Special:Contributions 页面查看来自维基百科帐户、IP 地址或 IP 范围的贡献。例如,https://en.wikipedia.org/wiki/Special:Contributions/193.224.28.151 lists the edits made from 193.224.28.151. You may also view edits from an IP range, like https://en.wikipedia.org/wiki/Special:Contributions/193.224.28.0/22.

如果您希望通过维基百科的 API 查看来自维基百科帐户和个人 IP 地址的贡献,请访问 https://www.mediawiki.org/wiki/API:Usercontribs

获取文档和示例

使用 Pywikibot 您可以按如下方式使用 MediaWiki API:

import pywikibot
site = pywikibot('Wikipedia:en')
user = pyikibot.User(site, '193.224.28.2')

User 是从 pywikibot.Page 派生的 class,它代表一个用户,并且有一种方法可以检索他的贡献。该方法是 contributions() ,它是一个生成器并产生 pywikibot.Page (一个页面对象,可用于获取更多信息), revid(修订 ID),pywikibot.Timestamp(从日期时间派生的对象),评论(编辑摘要)。要获取最后 5 次编辑,您可以使用:

contribs = list(user.contributions(total=5))

这会检索如下条目:

(Page('History of Croatia'), 282343057, Timestamp(2009, 4, 7, 14, 10, 7), '')

要获取一定范围的ips可以使用相应的站点方法usercontibs()但是你必须自己上传内容:

list(site.usercontribs(userprefix='193.224.28.', total=5))

对于每个条目,您都会得到一个这样的字典:

{'comment': '',
 'ns': 0,
 'pageid': 5574,
 'parentid': 281875336,
 'revid': 282343057,
 'timestamp': '2009-04-07T14:10:07Z',
 'title': 'History of Croatia',
 'user': '193.224.28.2',
 'userid': 0}

Site.usercontribs() 方法还有其他参数,这些参数也可用于 Page.contributions() .它们可用于过滤结果,例如对于特定的命名空间或仅检索页面的最顶层编辑。可以找到文档 here