Skip to content

webread

web · scripts/web/webread.m

: data = webread (url)
: data = webread (url, name1, value1, …)
: data = webread (…, opts)

Fetch the resource at url with an HTTP request and return its decoded body.

Pairs of names and values (strings or numbers) become the query string. A weboptions object given last controls the timeout, credentials, extra headers and the conversion of the reply: JSON text turns into structures and arrays, plain text into a character vector, images and audio into numeric arrays and CSV data into a table.

When the server cannot be reached the error identifier starts with MATLAB:webservices: (for example UnknownHost, ConnectionRefused or Timeout); an HTTP status of 400 or above gives MATLAB:webservices:HTTP<code>StatusCodeError.