Difference between revisions of "Http.get"
From ComputerCraft Wiki
(Moved to CAT:LuaCoreFunctions) |
(Type-templatify, link to handles documentation in API page, deduplicate description, tidy URL in example) |
||
Line 2: | Line 2: | ||
{{Function | {{Function | ||
|name=http.get | |name=http.get | ||
− | |args= | + | |args={{type|string}} url |
|api=HTTP | |api=HTTP | ||
− | |returns= | + | |returns={{type|table}} a [[HTTP (API)#Handles|handle]] on success, or [[nil]] on failure |
|addon=ComputerCraft | |addon=ComputerCraft | ||
− | |desc= | + | |desc=Sends a HTTP GET request to a website, synchronously. Returns when the request completes, successfully or not. |
|examples= | |examples= | ||
{{Example | {{Example | ||
|desc=Gets the content of example.com (in HTML) | |desc=Gets the content of example.com (in HTML) | ||
|code=local sExample = http.get("http://example.com/") --Get contents of page<br />write(sExample.readAll()) --Read and print contents of page<br />sExample.close() --Just in case | |code=local sExample = http.get("http://example.com/") --Get contents of page<br />write(sExample.readAll()) --Read and print contents of page<br />sExample.close() --Just in case | ||
− | |output=The source of example.com | + | |output=The source of http://example.com/ |
}} | }} | ||
}} | }} | ||
[[Category:Lua_Core_Functions]] | [[Category:Lua_Core_Functions]] |
Revision as of 23:14, 5 May 2013
Function http.get | |
Sends a HTTP GET request to a website, synchronously. Returns when the request completes, successfully or not. | |
Syntax | http.get(string url) |
Returns | table a handle on success, or nil on failure |
Part of | ComputerCraft |
API | HTTP |
Examples
Example | |
Gets the content of example.com (in HTML) | |
Code |
local sExample = http.get("http://example.com/") --Get contents of page |
Output | The source of http://example.com/ |