如果给出了字符串,则来自MediaWiki API请求:str = ` { "query": { "pages": { "66984": { "pageid": 66984, "ns": 0, "title": "Main Page", "touched": "2012-11-23T06:44:22Z", "lastrevid": 1347044, "counter": "", "length": 28, "redirect": "", "starttimestamp": "2012-12-15T05:21:21Z", "edittoken": "bd7d4a61cc4ce6489e68c21259e6e416+\\" } } }}`使用Go的json包可以做些什么来获得edittoken (请记住66984号将不断变化)?
2 回答
海绵宝宝撒
TA贡献1809条经验 获得超8个赞
请注意,如果您&indexpageids=true在API请求URL中使用参数,则结果将包含“ pageids”数组,如下所示:
str = ` {
"query": {
"pageids": [
"66984"
],
"pages": {
"66984": {
"pageid": 66984,
"ns": 0,
"title": "Main Page",
"touched": "2012-11-23T06:44:22Z",
"lastrevid": 1347044,
"counter": "",
"length": 28,
"redirect": "",
"starttimestamp": "2012-12-15T05:21:21Z",
"edittoken": "bd7d4a61cc4ce6489e68c21259e6e416+\\"
}
}
}
}`
因此您可以使用pageids[0]来访问不断变化的数字,这可能会使事情变得更容易。
- 2 回答
- 0 关注
- 205 浏览
添加回答
举报
0/150
提交
取消