获取给定维基百科页面的所有编辑者的列表

使用 Javascript/JQuery,我试图获取给定 Wikipedia 页面的所有编辑者的列表。我目前的方法感觉笨拙和缓慢,我想知道是否有更好的方法。

现在,我正在使用带有操作查询和属性修订的 MediaWiki API

https://en.wikipedia.org/w/api.php?action=query&prop=revisions&titles=Amy_Coney_Barrett&rvlimit=50&rvprop=timestamp%7Cuser%7Ccomment&format=json

然后我手动抓取 user 对象内的 revisions 对象。问题是查询每个可用修订的速度很慢,因为它返回大量细节,而不仅仅是编辑器名称。有没有更快的方法在 Javascript 中获取维基百科页面上唯一的编辑者列表?

weipei_200811 回答:获取给定维基百科页面的所有编辑者的列表

唯一身份用户?

除非有其他更简单的 API 调用,否则就是这样

/* fetch("https://en.wikipedia.org/w/api.php?action=query&prop=revisions&titles=Amy_Coney_Barrett&rvlimit=50&rvprop=timestamp%7Cuser%7Ccomment&format=json")
  .then(response => response.json())
  .then(data => process(data));
*/


const process = data => {
  return [...new Set(Object.values(data.query.pages)[0].revisions.map(rev => rev.user))]
}

const data = { "continue": { "rvcontinue": "20201228092417|996732970","continue": "||" },"query": { "normalized": [ { "from": "Amy_Coney_Barrett","to": "Amy Coney Barrett" } ],"pages": { "53992581": { "pageid": 53992581,"ns": 0,"title": "Amy Coney Barrett","revisions": [ { "user": "Davide King","timestamp": "2021-01-02T23:12:50Z","comment": "/* Early oral argument participation */ ce" },{ "user": "Swood100","timestamp": "2021-01-02T21:30:56Z","comment": "/* Textualism and originalism */ Restore space between words" },{ "user": "ToBeFree","timestamp": "2021-01-01T20:38:00Z","comment": "not that it really matters,but that's neither correct nor having any visible effect on the page" },{ "user": "Tbhotch","timestamp": "2021-01-01T20:06:10Z","comment": "Adding {{pp-move-indef}}" },{ "user": "Rich Farmbrough","timestamp": "2021-01-01T19:16:35Z","comment": "/* Suspension of habeas corpus */" },"timestamp": "2021-01-01T16:47:21Z","comment": "Adding {{pp-blp}}" },"timestamp": "2021-01-01T16:47:20Z","comment": "Changed protection level for \"[[Amy Coney Barrett]]\": Violations of the [[WP:BLP|biographies of living persons policy]] ([Edit=Require autoconfirmed or confirmed access] (expires 16:47,1 February 2021 (UTC)) [Move=Require administrator access] (expires 00:34,26 January 2021 (UTC)))" },{ "user": "ClueBot NG","timestamp": "2021-01-01T16:45:01Z","comment": "Reverting possible vandalism by [[Special:Contribs/76.69.81.193|76.69.81.193]] to version by Biglittlehugesmall65. [[WP:CBFP|Report False Positive?]] Thanks,[[WP:CBNG|ClueBot NG]]. (3857048) (Bot)" },{ "user": "76.69.81.193","anon": "","timestamp": "2021-01-01T16:44:51Z","comment": "Undid revision 997659065 by [[Special:Contributions/Biglittlehugesmall65|Biglittlehugesmall65]] ([[User talk:Biglittlehugesmall65|talk]])" },{ "user": "Biglittlehugesmall65","timestamp": "2021-01-01T16:44:12Z","comment": "Reverted 1 edit by [[Special:Contributions/76.69.81.193|76.69.81.193]] ([[User talk:76.69.81.193|talk]]) to last revision by Eyer" },"timestamp": "2021-01-01T16:43:49Z","comment": "Undid revision 997658781 by [[Special:Contributions/Eyer|Eyer]] ([[User talk:Eyer|talk]])" },{ "user": "Eyer","timestamp": "2021-01-01T16:42:35Z","timestamp": "2021-01-01T16:41:35Z","comment": "" },"timestamp": "2021-01-01T16:40:13Z","comment": "ce,capitalization,[[MOS:JOBTITLES]] (modified by \"an\")" },{ "user": "User3749","timestamp": "2021-01-01T16:33:59Z","comment": "Reverted 1 edit by [[Special:Contributions/2605:8D80:681:96FD:1DDD:3E67:126F:2C|2605:8D80:681:96FD:1DDD:3E67:126F:2C]] ([[User talk:2605:8D80:681:96FD:1DDD:3E67:126F:2C|talk]]) to last revision by User3749" },{ "user": "2605:8D80:681:96FD:1DDD:3E67:126F:2C","timestamp": "2021-01-01T16:33:24Z","comment": "Undid revision 997656696 by [[Special:Contributions/User3749|User3749]] ([[User talk:User3749|talk]])" },"timestamp": "2021-01-01T16:32:35Z","comment": "Reverted 1 edit by [[Special:Contributions/2605:8D80:681:96FD:1DDD:3E67:126F:2C|2605:8D80:681:96FD:1DDD:3E67:126F:2C]] ([[User talk:2605:8D80:681:96FD:1DDD:3E67:126F:2C|talk]]) to last revision by CLCStudent" },"timestamp": "2021-01-01T16:32:04Z","comment": "Undid revision 997655513 by [[Special:Contributions/CLCStudent|CLCStudent]] ([[User talk:CLCStudent|talk]])" },{ "user": "CLCStudent","timestamp": "2021-01-01T16:27:22Z","comment": "Reverted 1 edit by [[Special:Contributions/24.114.76.33|24.114.76.33]] ([[User talk:24.114.76.33|talk]]) to last revision by Serols" },{ "user": "24.114.76.33","timestamp": "2021-01-01T16:27:15Z","comment": "Undid revision 997655400 by [[Special:Contributions/Serols|Serols]] ([[User talk:Serols|talk]])" },{ "user": "Serols","timestamp": "2021-01-01T16:26:54Z","comment": "Reverted edits by [[Special:Contributions/24.114.76.33|24.114.76.33]] ([[User talk:24.114.76.33|talk]]) ([[WP:HG|HG]]) (3.4.10)" },"timestamp": "2021-01-01T16:26:42Z","comment": "Undid revision 997655124 by [[Special:Contributions/Serols|Serols]] ([[User talk:Serols|talk]])" },"timestamp": "2021-01-01T16:25:54Z","timestamp": "2021-01-01T16:25:32Z","comment": "Undid revision 997654753 by [[Special:Contributions/Serols|Serols]] ([[User talk:Serols|talk]])" },"timestamp": "2021-01-01T16:24:31Z","timestamp": "2021-01-01T16:24:12Z","comment": "Undid revision 997654591 by [[Special:Contributions/Serols|Serols]] ([[User talk:Serols|talk]])" },"timestamp": "2021-01-01T16:23:52Z","timestamp": "2021-01-01T16:23:10Z","comment": "Undid revision 997654306 by [[Special:Contributions/Serols|Serols]] ([[User talk:Serols|talk]])" },"timestamp": "2021-01-01T16:22:41Z","timestamp": "2021-01-01T16:22:26Z",{ "user": "BartocX","timestamp": "2020-12-31T18:35:10Z",{ "user": "2603:9001:2501:2B00:E80C:F610:6371:1B43","timestamp": "2020-12-31T04:27:18Z",{ "user": "Keith D","timestamp": "2020-12-30T19:53:39Z","comment": "/* Second Amendment */ Remove full stop" },{ "user": "Unknown0124","timestamp": "2020-12-30T16:00:40Z","comment": "/* Nomination to the Supreme Court */Removing biased statement" },{ "user": "WikiCleanerBot","timestamp": "2020-12-30T10:35:02Z","comment": "v2.04b - [[User:WikiCleanerBot#T20|Bot T20 CW#61]] - Fix errors for [[WP:WCW|CW project]] (Reference before punctuation)" },{ "user": "2600:6C51:7580:5564:20AB:1817:61EA:3A25","timestamp": "2020-12-30T09:45:07Z","comment": "/* Nomination to the Supreme Court */" },{ "user": "70.172.7.12","timestamp": "2020-12-30T09:28:09Z",{ "user": "AlsoWukai","timestamp": "2020-12-29T23:57:38Z","comment": "/* First publicly discernible vote as a justice */ ce" },{ "user": "LizardJr8","timestamp": "2020-12-29T22:38:08Z","comment": "Reverted edits by [[Special:Contributions/2604:3D09:1F88:4700:BDB7:F5F5:DF11:33A5|2604:3D09:1F88:4700:BDB7:F5F5:DF11:33A5]] ([[User talk:2604:3D09:1F88:4700:BDB7:F5F5:DF11:33A5|talk]]) ([[WP:HG|HG]]) (3.4.10)" },{ "user": "2604:3D09:1F88:4700:BDB7:F5F5:DF11:33A5","timestamp": "2020-12-29T22:37:39Z","timestamp": "2020-12-29T22:35:00Z","comment": "fixed her title<3" },"timestamp": "2020-12-29T19:48:04Z","comment": "/* Personal life */ How Barrett and her husband are able to care for seven children while holding down jobs is relevant." },{ "user": "P3Y229","timestamp": "2020-12-29T09:44:03Z","comment": "/* First publicly discernible vote as a justice */ - Added content and sources" },"timestamp": "2020-12-29T09:43:20Z","comment": "Undid revision 996952623 by [[Special:Contributions/P3Y229|P3Y229]] ([[User talk:P3Y229|talk]]) - Reason: To add a edit summary" },"timestamp": "2020-12-29T09:41:16Z","comment": "/* First publicly discernible vote as a justice */" },"timestamp": "2020-12-29T04:22:08Z","comment": "ce" },{ "user": "OgamD218","timestamp": "2020-12-28T16:21:51Z","comment": "/* Personal life */ an aunt assisting with the childcare of her nieces and nephews in and of itself as presented here does not belong in an encyclopedia" },{ "user": "2600:1700:8C40:2F70:25AE:46DC:8C65:C710","timestamp": "2020-12-28T16:12:46Z","comment": "/* U.S. Supreme Court (2020–present) */" },{ "user": "Ashleyyoursmile","timestamp": "2020-12-28T09:30:32Z","comment": "Reverted 1 edit by [[Special:Contributions/Editor.angel23|Editor.angel23]] ([[User talk:Editor.angel23|talk]]) to last revision by ClueBot NG" },{ "user": "Editor.angel23","timestamp": "2020-12-28T09:28:59Z","comment": "these are just the correct names" } ] } } } };

console.log(process(data))

例如@Ainali 指出的贡献者

/* fetch("https://en.wikipedia.org/w/api.php?action=query&prop=contributors&titles=Amy_Coney_Barrett&rvlimit=50&rvprop=timestamp%7Cuser%7Ccomment&format=json")
  .then(response => response.json())
  .then(data => process(data));
*/


const process = data => {
  return [...new Set(Object.values(data.query.pages)[0].contributors.map(cont => cont.name))]
}

const data = { "warnings": { "main": { "*": "Unrecognized parameters: rvlimit,rvprop." } },"continue": { "pccontinue": "53992581|475","anoncontributors": 121,"contributors": [ { "userid": 124152,"name": "Philip Cross" },{ "userid": 27015025,"name": "InternetArchiveBot" },{ "userid": 7611264,"name": "AnomieBOT" },{ "userid": 24684472,"name": "MusikBot" },{ "userid": 1215485,"name": "Cydebot" },{ "userid": 1763353,"name": "MelanieN" },{ "userid": 279219,"name": "RussBot" },{ "userid": 7903804,"name": "Citation bot" },{ "userid": 237572,"name": "GünniX" },{ "userid": 32005,"name": "Timrollpickering" } ] } } } };

console.log(process(data))

本文链接:https://www.f2er.com/1162263.html

大家都在问