lua-users home
lua-l archive

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


Hi Vadim

Thanks for the reply, yes I could already get the BBC home page, so that didnt really help me solve my problem

Try getting the http://www.bbc.co.uk/sport/football/results site and then programmatically navigate to the Premier League results page ? Thats where I am stuck.

I would be happy to use any Lua library that solves the above problem. LuaSocket, luacurl both can probably due the job in a few lines of code if I can figure out the GET param string and how to specify it.

Regards Geoff


________________________________________
From: lua-l-bounces@lists.lua.org <lua-l-bounces@lists.lua.org> on behalf of Vadim A. Misbakh-Soloviov <lua-l@mva.name>
Sent: 08 May 2016 21:53:54
To: Lua mailing list
Subject: Re: Question about LuaSocket and HTTP

>
> At this point I am stuck, how do I specifiy this GET selection string in the
> Lua example above ?

In your current case I'd suggest something like:

    url1= [[/sport/football/results]]

    http.request(
        {
            url = [[http://www.bbc.co.uk]]..url1,
            sink = ltn12.sink.file(fileHandle),
        })

and operate with "url1" variable (there will be GET request with exactly it's
content.

But...

Are you sure that you want exactly luasocket and ltn12? ;)

There is luacurl (C) and luahtmlparser (pure Lua) libraries, which, when
combined, gives some magic powers to easily fetch and parse every site in
about 10 lines of code :)

--
wbr,
mva