lua-users home
lua-l archive

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


I suppose this does not answer your question, but ... if you don't
explicitly need SSL, you can get away with curl.

I figured out the 'if' below a year or two ago, and now just
cut-and-paste it every time.

Having loaded lua-curl as "curl", this is all:

logins = {}
session = curl.easy()
if curl.OPT_COOKIEFILE and curl.OPT_COOKIEJAR then
    cookies = os.tmpname()
    session:setopt(curl.OPT_COOKIEFILE,cookies)
    session:setopt(curl.OPT_COOKIEJAR,cookies)
    logins[session] = cookies
  else
    message("Your 'curl' does not support cookies. You will be anonymous.")
  end
session:setopt{url="https://www.attheraces.com/racecards",writefunction=print}:perform()

I see the entire HTML code of the landing page.

To store it in a table, just put something like 'function(str)
table.insert(buffer,str) end' instead of 'print' having done
'buffer={}' first.



Op Ma. 25 Mrt. 2019 om 13:51 het Geoff Smith <spammealot1@live.co.uk> geskryf:
>
> I am trying to download a webpage using Lua 5.1 and Luasec (not sure which version)
>
> I am seeing the same error on several pages, but one example is [[https://www.attheraces.com/racecards]]
> I am getting an error stating "sslv3 alert handshake failure"
>
> I am not an expert on the https protocol so not sure what I need to do to fix this problem. I am assuming i need to tell it to use TLS v1.2 or later to make it work. Not proved that this is the problem though. Here is gist of my latest code attempt that still gives me the same error.
>
> ssl.newcontext({mode="client", protocol="tlsv1_2"})
>
> local url = [[https://www.attheraces.com/racecards]]
>
> webText, code, headers, status = https.request({url=url,  protocol="tlsv1_2"})
> print(code, headers, status)
>
> I have tried protocol = "sslv23" and "sslv3"  neither fixed the problem
>
> Any help on this issue would be most appreciated, thanks.
>
>
>
>
>
>
>
> Virus-free. www.avast.com