Reorganize examples tree.
parent
bf4b8b0b0b
commit
a50ffe9997
|
@ -4,7 +4,7 @@
|
|||
-- RCS ID: $Id: browser.lua,v 0.1 2011/03/11 23:55:20 kai Exp $
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
local cURL = require("lcurl.cURL")
|
||||
local cURL = require("cURL")
|
||||
local string = require("string")
|
||||
local table = require("table")
|
||||
local base = _G
|
|
@ -1,4 +1,4 @@
|
|||
local cURL = require("lcurl.cURL")
|
||||
local cURL = require("cURL")
|
||||
|
||||
-- open output file
|
||||
f = io.open("example_homepage", "w")
|
||||
|
@ -7,9 +7,9 @@ c = cURL.easy_init()
|
|||
-- setup url
|
||||
c:setopt_url("http://www.example.com/")
|
||||
-- perform, invokes callbacks
|
||||
c:perform({writefunction = function(str)
|
||||
f:write(str)
|
||||
end})
|
||||
c:perform{writefunction = function(str)
|
||||
f:write(str)
|
||||
end}
|
||||
|
||||
-- close output file
|
||||
f:close()
|
|
@ -1,15 +1,15 @@
|
|||
local cURL = require("lcurl.cURL")
|
||||
local cURL = require("cURL")
|
||||
|
||||
-- setup easy
|
||||
c = cURL.easy_init()
|
||||
c1 = cURL.easy_init()
|
||||
c2 = cURL.easy_init()
|
||||
|
||||
-- setup url
|
||||
c:setopt_url("http://www.lua.org/")
|
||||
c1:setopt_url("http://www.lua.org/")
|
||||
c2:setopt_url("http://luajit.org/")
|
||||
|
||||
m = cURL.multi_init()
|
||||
m:add_handle(c)
|
||||
m:add_handle(c1)
|
||||
m:add_handle(c2)
|
||||
|
||||
local f1 = io.open("lua.html","a+")
|
||||
|
@ -17,6 +17,6 @@ local f2 = io.open("luajit.html","a+")
|
|||
|
||||
for data, type, easy in m:perform() do
|
||||
-- if (type == "header") then print(data) end
|
||||
if (type == "data" and c == easy) then f1:write(data) end
|
||||
if (type == "data" and c1 == easy) then f1:write(data) end
|
||||
if (type == "data" and c2 == easy) then f2:write(data) end
|
||||
end
|
|
@ -1,4 +1,4 @@
|
|||
local cURL = require("lcurl.cURL")
|
||||
local cURL = require("cURL")
|
||||
|
||||
-- returns size and reader
|
||||
local function make_stream(ch, n, m)
|
|
@ -1,6 +1,6 @@
|
|||
-- use LuaExpat and Lua-CuRL together for On-The-Fly XML parsing
|
||||
local lxp = require("lxp")
|
||||
local cURL = require("lcurl.cURL")
|
||||
local cURL = require("cURL")
|
||||
|
||||
tags = {}
|
||||
items = {}
|
||||
|
@ -14,12 +14,13 @@ function callback.StartElement(parser, tagname)
|
|||
end
|
||||
end
|
||||
|
||||
function callback.CharacterData(parser, str)
|
||||
function callback.CharacterData(parser, str)
|
||||
if (tags[#tags -1] == "item") then
|
||||
--we are parsing a item, get rid of trailing whitespace
|
||||
items[#items][tags[#tags]] = string.gsub(str, "%s*$", "")
|
||||
end
|
||||
end
|
||||
|
||||
function callback.EndElement(parser, tagname)
|
||||
--assuming well formed xml
|
||||
tags[#tags] = nil
|
Loading…
Reference in New Issue