nickik
nickik

Reputation: 5881

get html with lua

Halo,

I'm trying to make a awesome widget. I would like do download information from a website but I don't know lua and I didn't found anything good on the web.

I would like to pass in a domainname or a IP and get back the html code.

Thanks for your help.

Upvotes: 5

Views: 10023

Answers (4)

Matthew Blanchard
Matthew Blanchard

Reputation: 508

On Ubuntu and other popular Linux distros at least you can get luasocket from your package manager and then use that.

local http = require("socket.http")
local page = http.request("http://www.google.com")

Upvotes: 0

ponzao
ponzao

Reputation: 20944

I would recommend using LuaSocket. It is probably included in your system package manager's repositories and if not you can easily get it with LuaRocks.

$ luarocks install luasocket
$ lua
> require 'luarocks.require'
> http = require 'socket.http'
> html = http.request 'http://www.google.com'

Upvotes: 13

moinudin
moinudin

Reputation: 138497

Use webGet:

require('webGet')
cli = webGet.new{}
local address = 'http://www.strixDB.com/samples/animals.rdf'
local rc,error=cli:GET(address, print) -- print the file

Upvotes: 2

Check out http://lua-curl.luaforge.net/.

Upvotes: 2

Related Questions