Module:Extract:修订间差异
武外梗百科 爱国好学自强图新的百科全书
更多操作
无编辑摘要 |
无编辑摘要 |
||
| 第2行: | 第2行: | ||
function p.extractLead(frame) | function p.extractLead(frame) | ||
local page = frame.args[1] | local page = frame.args[1] | ||
local sentences = tonumber(frame.args[2]) or 2 | local sentences = tonumber(frame.args[2]) or 2 | ||
| 第15行: | 第14行: | ||
end | end | ||
local api = mw. | -- Scribunto 正确 API 用法 | ||
local api = mw.api.new() | |||
local result = api:get({ | local result = api:get({ | ||
action = "query", | action = "query", | ||
| 第24行: | 第25行: | ||
}) | }) | ||
if not result or not result.query or not result.query.pages then | if not result | ||
or not result.query | |||
or not result.query.pages | |||
then | |||
return "" | return "" | ||
end | end | ||
for _, v in pairs(result.query.pages) do | for _, v in pairs(result.query.pages) do | ||
if v.extract and v.extract ~= "" then | |||
return v.extract | |||
end | |||
end | end | ||