webread
Read data from RESTful web service to Nelson's variable
📝Syntax
var = webread(url)
var = webread(url, name1, value1, ... , nameN, valueN)
var = webread(url, name1, value1, ... , nameN, valueN, options)
📥Input Arguments
Parameter Description
url a string: URL to a web service.
name1, value1, ... , nameN, valueN Name-Value Pair Arguments.
options a weboptions object.
📤Output Arguments
Parameter Description
var a variable: content from web.
📄Description

webread() reads content from the web to nelson's variable.

HTTP redirects are followed by default (see FollowLocation in weboptions).

When ContentType is 'auto' (the default), the Content-Type header of the response selects the decoder: an image/* response is read with imread, an audio/* response with audioread and a JSON response with jsondecode. Other media types are detected from the content.

💡Examples
url = 'https://httpbin.org/get';
res = webread(url,weboptions('ContentType','json'));
More demos
edit([modulepath('webtools'),'/examples/webread_demo_1.m'])
Use function_handle with weboptions and webread
edit([modulepath('webtools'),'/examples/webread_demo_2.m'])
Read data from National Agricultural Statistics Service
edit([modulepath('webtools'),'/examples/webread_demo_3.m'])
🔗See Also
weboptionswebsave
🕔Version History
Version Description
1.0.0 initial version
2.0.0 redirects followed by default, 'auto' content type uses the response Content-Type header
Edit this page on GitHub