在客户端显示页面(使用socket.request从lua获取数据)
问题描述:
我正在尝试使用lua访问跨域服务器。 我收到服务器的响应(html代码)。 现在,我需要这个页面,我必须在我的网站上显示。在客户端显示页面(使用socket.request从lua获取数据)
代码:
--body, header, status, error
b, h, s, e = socket.http.request{url = "http://someurl"
, proxy = "http://someProxy"
, sink = ltn12.sink.file(io.stdout)
}
水槽属性做他的工作,并打印HTML返回给客户端。 在客户端我正在开发与extjs。 我的问题是,我如何显示已收到的页面?
THX, 号Yoni
答
我想你想输出捕捉到在Lua的字符串,而不是水槽是io.stdout
,然后使用该字符串的“3 ways to render HTML inside of a ExtJS container”之一。
至于将数据写入字符串而不是标准输出,看起来像这样的:
local t = {}
sink = ltn12.sink.table(t)
-- ...
local html = table.concat(t)