
--gethtml
function gethtml (url)
local sz = require("sz")
local http = require("szocket.http")
local res, code = http.request(url); return res end
---------------------------------------------------------------------------
-- r w a分别为 读 写 追加
--write
function writenew(url,data)
local file = io.open(url, "w");
assert(file);
file:write(data);
file:close();
end
-----------------------------------------------------------------------------
--write append
function writeappend(url,data)
local file = io.open(url, "a"); file:write(data);
file:close();
end
------------------------------------------------------------------------------
--read to table
function read(url)
local x = {}
local file = io.open(url, "r");
assert(file);
local data = file:read(); -- 读取所有内容
while data do
table.insert(x,data);
data = file:read()
end
file:close();
return x
end