触动精灵 alilib

--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

 

posted @ 2016-05-14 22:20  Ali.Blacken  阅读(305)  评论(0编辑  收藏  举报