webread
Read content from RESTful web service
Syntax
描述
appends query parameters to数据
= webread(url
,QueryName1,QueryValue1,...,QueryNameN,QueryValueN
)url
, as specified by one or more pairs of name-value arguments. To put a query into the body of the message, useWebwrite
。Web服务定义查询参数。
adds other HTTP request options, specified by the数据
= webread(___,options
)weboptions
objectoptions
。You can use this syntax with any of the input arguments of the previous syntaxes.
To return data as a specific output type, specify theContentType
property ofoptions
。
To read content with a function, specify theContentReader
property ofoptions
作为一个handle to the function.webread
从Web服务下载数据,并使用指定功能读取数据:
If you specify a handle to a function that returns multiple output arguments,
webread
returns all output arguments.If you specify a handle to a function that returns no output argument (such as Image Processing Toolbox™ function
@implay
for video files),webread
returns no output argument.
[
reads an image from the web service specified by数据
,colormap
,alpha
这是给予的= webread(___)url
and returns the image in数据
。您可以使用先前的语法仅返回图像。使用此语法返回与图像关联的colormap和alpha通道。
webread
returns an image when the HTTP response has aContent-Type
header field that specifies an image media type and ifimread
supports the image format. For supported image formats, seeSupported File Formats for Import and Export。
[
reads audio data from the web service specified by数据
,Fs
这是给予的= webread(___)url
and returns the audio data in数据
。You can use the previous syntaxes to return the audio data only. Use this syntax to return the sample rate of the audio data in hertz.
webread
returns audio data when the HTTP response has aContent-Type
header field that specifies an audio media type and ifaudioread
supports the audio format. For supported audio formats, seeSupported File Formats for Import and Export。
Examples
Input Arguments
Output Arguments
More About
提示
For functionality not supported by the RESTful web services functions, see theUse HTTP with MATLAB。
webread
supports HTTP GET and POST methods. Many web services provide both GET and POST methods to request data. To send an HTTP POST request, specify theRequestMethod
property ofoptions
as'post'
。However,webread
将查询选项放入url
, not in the body of the request message. To put a query into the body, useWebwrite
。For HTTP POST requests, the
webread
function supports only the应用/X-WWW-Form-urlenCoded
media type. To send a POST request with content of any other internet media type, useWebwrite
。This function does not examine the document contents to determine how to process it. For example, HTML and XML documents often contain a
tag that specifies the document character encoding. If the encoding is different from the default
webread
encoding, then specify the correctCharacterEncoding
option inweboptions
。To specify proxy server settings, seeProxy Server Authentication。
H版istory
See Also
websave
|weboptions
|Webwrite
|datetime
|jsondecode
|audioread
|imread
|readtable
|xmlread