更多操作
创建页面,内容为“local p = {} local http = require("socket.http") local ltn12 = require("ltn12") local json = require("dkjson") local url = "https://store.steampowered.com/api/appdetails?appids=245170&cc=cn&filters=price_overview" local response = {} local res, code, response_headers, status = http.request{ url = url, sink = ltn12.sink.table(response) } if code == 200 then local data = json.decode(table.concat(response)) local priceOverview = data["245170"].dat…” |
无编辑摘要 |
||
第5行: | 第5行: | ||
local url = "https://store.steampowered.com/api/appdetails?appids=245170&cc=cn&filters=price_overview" | local url = "https://store.steampowered.com/api/appdetails?appids=245170&cc=cn&filters=price_overview" | ||
local response = {} | local response = {} | ||
local data = json.decode(table.concat(response)) | |||
local priceOverview = data["245170"].data.price_overview | |||
function p.discount() | function p.discount() |
2025年1月14日 (二) 22:32的版本
此模块的文档可以在模块:SteamPrice/doc创建
local p = {}
local http = require("socket.http")
local ltn12 = require("ltn12")
local json = require("dkjson")
local url = "https://store.steampowered.com/api/appdetails?appids=245170&cc=cn&filters=price_overview"
local response = {}
local data = json.decode(table.concat(response))
local priceOverview = data["245170"].data.price_overview
function p.discount()
return string.format('%s', priceOverview.discount_percent)
end
function p.price()
return string.format('%s', priceOverview.final)
end
return p