Uses standard windows http request object to return data from any web page. In the example XML will contain the source of the FHUG home page.
Requires: luacom
Code
-
require('luacom') http = luacom.CreateObject("winhttp.winhttprequest.5.1") http:Open("GET","http://www.fhug.org.uk",false) http:Send() data = http.Responsebody text = http.Responsetext
- NOTE: If the file is sent in binary mode (for example plugin download) use ResponseBody rather than ResponseText as text can have unpredictable truncation which seems to be related to the text being converted to UTF-8.
- NOTE: Text supplied by ResponseBody and ResponseText terminates each line with CRLF that may often benefit from converting to just a LF character using:
data:gsub("\r\n","\n")