打开/关闭菜单
60
73
29
1.1K
武外梗百科
打开/关闭外观设置菜单
打开/关闭个人菜单
未登录
未登录用户的IP地址会在进行任意编辑后公开展示。

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.ext.Api
    -- 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
         return v.extract or ""
         if v.extract and v.extract ~= "" then
            return v.extract
        end
     end
     end