HTTP GET request.
[result, status, headers] = http_get(url) [result, status, headers] = http_get(url, <opt_args>) [result, status, headers] = http_get(url, filename) [result, status, headers] = http_get(url, filename, <opt_args>)
A string containing the server address following by the optional port, the route of the request and query datas. syntax: "address:port/route?queryfield=querydata"
If this optional argument is given, the result will be written in the file. Can be used to download a file.
This represents a sequence of statements
key1=value1, key2=value2, ...
where key1
,
key2
, ... can be one of the following:
Strings defined as "name: value"
.
Strings defined as "name=value"
.
This parameter is used to send custom cookies regardless of cookie preferences.
Those cookies are sent in addition to stored cookies.
This option determines whether Scilab verifies the authenticity
of the peer's certificate.
If none
is given, no verification is performed.
![]() | Disabling verification of the certificate allows bad guys
to man-in-the-middle the communication without you knowing it.
Disabling verification makes the communication insecure.
Just having encryption on a transfer is not enough as you
cannot be sure that you are communicating with the correct
end-point. |
By default, follow
is false.
Set follow=%t
to follow eventual redirections.
Username and password can be specified for the websites which required authentication.
The syntax is auth="username:password"
This option displays information in the Scilab console to diagnose potential network issues.
It is disabled by default, set verbose=%t
to display the in-progress log.
Set the maximum time in seconds that you allow the request to take. Millseconds can be set by using a floating point value. ie: 0.5 will set a timeout of 500 ms. When the timeout is reached, the function returns an error.
If a filename is given, result contains the path of the file. If not, result is a string which contain the server answer or a Scilab variable if the answer is in JSON format.
HTTP response code.
struct: HTTP headers of the request result.
![]() | When the optional argument follow is set to %t ,
all headers are returned in a list that contains one struct per request made to follow redirections. |
This function will perform an HTTP GET request.
The proxy configuration is used if it's enabled in the Preferences under the rubric "Web".
The cookies configuration under the "Web" rubric is used.
No cookies are used and store.
Cookies are used and store. They are keeped between Scilab sessions.
They are stored in SCIHOME/cookies.txt
.
Cookies are used and store. They are deleted at Scilab close.
They are stored in TMPDIR/cookies.txt
.
result = http_get("www.google.com") file = http_get("www.google.com", TMPDIR+"/result"); mgetl(file) file = http_get("www.google.com", TMPDIR+"/result.html", follow=%t); // then open the file in your browser result = http_get("https://jsonplaceholder.typicode.com/posts?userId=1") // set specific headers result = http_get("https://jsonplaceholder.typicode.com/posts?userId=1", headers=["myheader: user_header", "token: sdfrufhfDF42"], verbose=%t) | ![]() | ![]() |
Version | Description |
6.1 | Function introduced. |
2024.1 | headers output argument added. |