lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi.  In   /usr/lib/lua/5.1/curl.so   there is a curl module which
presumably is there as a by-product of   aptitude install luarocks

In  http://luaforge.net/projects/luacurl/  it says
   The module interface follows strictly the cURL architecture and is
   very easy to use if the programmer has already experience with cURL.
I really like that dry sense of humour :-)  Fortunately there are
a number of websites around that collect working libcurl examples.

I also found   http://luacurl.luaforge.net/   which is good doc,
but seems out of date; like it mentions curl.new() and curl.close,
which do not appear in:
  require('curl') ; for x in pairs(curl) do print(x) end
In an ideal world, this might perhaps be updated and linked to
from a 'Doc" button in  http://luaforge.net/projects/luacurl/  ?

Peter

P.S.  I've ended up using:
  function wget(url)
    local text = {}
    local function WriteMemoryCallback(s)
        text[#text+1] = s
        return string.len(s)
    end
    local c = curl.easy_init()
    c:setopt(curl.OPT_URL, url)
    c:setopt(curl.OPT_WRITEFUNCTION, WriteMemoryCallback)
    c:setopt(curl.OPT_USERAGENT, "luacurl-agent/1.0")
    c:perform()
    return table.concat(text,'')
  end

http://www.pjb.com.au       pj@pjb.com.au      (03) 6278 9410
"Was der Meister nicht kann,   vermöcht es der Knabe, hätt er
 ihm immer gehorcht?"   Siegfried to Mime, from Act 1 Scene 2