Returns the contents of a URL.
GETURL("url", "targfile", "header", "typestr", "cmdtype", bufsize)
"url" |
- |
A string, the source URL address. |
||||||
"targfile" |
- |
Optional. A string, the target file name to receive the contents of the URL. Defaults to "" (empty), the contents are returned directly. |
||||||
"header" |
- |
Optional. A string, the HTML header string. Defaults to empty, no header. |
||||||
"typestr" |
- |
Optional. A string. The returned data type: |
||||||
|
|
|
||||||
"cmdtype" |
- |
Optional A string. The HTML command. Defaults to "GET". |
||||||
bufsize |
- |
Optional. An integer. The initial size of the HTML transfer buffer. Defaults to 65536. |
If targfile is not empty, returns the full path to targfile.
If targfile is empty, directly returns a string or series, the value of the HTML request.
(result, status, errmes) = GETURL("url", "", "header", "typestr", "cmdtype", bufsize) returns the value, integer status and error string.
geturl("www.dadisp.com")
Returns the HTML text for the DADiSP home page.
viewtext(geturl("www.dadisp.com"))
Same as above, except the web page HTML text is displayed in a popup box.
url = "https://vpic.nhtsa.dot.gov/api/vehicles/getallmanufacturers?format=json";
hed = "Content-Type: application/json" + strescape("\r\n");
jstr = geturl(url, "", hed);
Returns a JSON object string from the URL. To convert the string to an actual object, use OBJJSONSTR:
jobj = objjsonstr(jstr);
readjson("https://vpic.nhtsa.dot.gov/api/vehicles/getallmanufacturers?format=json")
Same as above except the JSON object is read and returned directly.
viewhtml(geturl("https://en.wikipedia.org/wiki/UTF-8", getmiscpath(1, 1) + "temp.htm"))
Downloads the HTML contents to a temp file and displays the result.
GETURL returns the contents of the URL as specified by the header, typestr and cmdtype.
If targfile is empty, the result is returned directly. If targfile is not empty, the result is written to targfile.
The result is buffered. If the result is returned directly, the initial output buffer size is doubled until it fits the final result.
GETURL is a low level routine for HTML data transfers.
See PUTURL to put data to a URL.
See READJSON to load a JSON object from a file or URL.