Difference between revisions of "Http.get"
From ComputerCraft Wiki
(anh con may cung voi coi nha) |
|||
(9 intermediate revisions by 5 users not shown) | |||
Line 1: | Line 1: | ||
− | + | {{lowercase}} | |
+ | {{Function | ||
+ | |name=http.get | ||
+ | |args={{type|string}} url [, {{type|table}} headers] | ||
+ | |api=HTTP | ||
+ | |returns={{type|table}} a [[HTTP (API)#Handles|handle]] on success, or [[nil]] on failure | ||
+ | |addon=ComputerCraft | ||
+ | |desc=Sends a HTTP GET request to a website, synchronously. Returns when the request completes, successfully or not. | ||
+ | |examples= | ||
+ | {{Example | ||
+ | |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 | ||
+ | |output=The source of http://example.com/ | ||
+ | }} | ||
+ | }} | ||
+ | |||
+ | [[Category:Lua_Core_Functions]] |
Latest revision as of 19:54, 20 April 2014
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 [, table headers]) |
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/ |