http.Fetch
Example
Shows the typical usage to get the HTML of a webpage.
local theReturnedHTML = "" -- Blankness
http.Fetch( "https://www.google.com",
-- onSuccess function
function( body, length, headers, code )
-- The first argument is the HTML we asked for.
theReturnedHTML = body
end,
-- onFailure function
function( message )
-- We failed. =(
print( message )
end,
-- header example
{
["accept-encoding"] = "gzip, deflate",
["accept-language"] = "fr"
}
)
Output: If it successfully fetched the page, the variable
theReturnedHTML
should contain the returned HTML in plain text.