Difference between revisions of "Http.get"

From ComputerCraft Wiki
Jump to: navigation, search
(Moved to CAT:LuaCoreFunctions)
Line 14: Line 14:
 
}}
 
}}
 
}}
 
}}
 +
 +
[[Category:Lua_Core_Functions]]

Revision as of 18:49, 28 November 2012


Grid Redstone.png  Function http.get
Returns a table similar to that returned by an fs.open() call, used to handle the response of the server on success or nil on failure.
Syntax http.get(string url)
Returns The response of the server on success or nil on failure.
Part of ComputerCraft
API HTTP

Examples

Grid paper.png  Example
Gets the content of example.com (in HTML)
Code
local sExample = http.get("http://example.com/") --Get contents of page
write(sExample.readAll()) --Read and print contents of page
sExample.close() --Just in case
Output The source of example.com