全站通知:
模块:提取公众号数据
刷
历
编
跳到导航
跳到搜索
此模块的文档可以在模块:提取公众号数据/doc创建
local p = {}
function p.getData( frame )
local targetPage = mw.title.new(frame.args.page)
if targetPage.exists then
local content = targetPage:getContent()
local result = ""
for articleContent in string.gmatch(content, "{{公众号(.-)}}") do
local authorAvatar = string.match(articleContent, "|发布者头像=%[%[File:([^\n|]+)%.png%]%]")
local authorName = string.match(articleContent, "|发布者名称=([^\n|]+)")
local articleTitle = string.match(articleContent, "|标题=([^\n|]+)")
local articleImage = string.match(articleContent, "%[%[[fF]ile:公众号%-([^\n|]+%.[jJpP][nNpP][gG])%]%]")
articleImage = articleImage or ""
if authorAvatar and authorName and articleTitle then
result = result .. "{{沙盒/14|发布者头像=" .. authorAvatar ..
"|发布者名称=" .. authorName ..
"|公众号图片=" .. articleImage ..
"|标题=" .. articleTitle .. "}}"
end
end
if result == "" then
return "No articles found"
else
return frame:preprocess(result)
end
else
return "Page does not exist" .. frame.args.page
end
end
return p