码迷,mamicode.com
首页 > 其他好文 > 详细

触动精灵 alilib

时间:2016-05-14 23:07:50      阅读:340      评论:0      收藏:0      [点我收藏+]

标签:

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

 

触动精灵 alilib

标签:

原文地址:http://www.cnblogs.com/aliblogs/p/5493720.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!