加载中…
个人资料
  • 博客等级:
  • 博客积分:
  • 博客访问:
  • 关注人气:
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

Matlab webread 函数 Matlab爬虫

(2017-04-05 10:40:03)
标签:

matlab爬虫

webread

分类: Matlab

webread

Read content from RESTful web service


Syntax

data = webread(url)
data = webread(url,QueryName1,QueryValue1,...,QueryNameN,QueryValueN)
data = webread(___,options)
[data,colormap,alpha] = webread(___)
[data,Fs] = webread(___)

Description


data = webread(url) reads content from the web service specified by url and returns the 

content in data.

The web service provides a RESTful API that returns data formatted as an internet media

 type such as JSON, XML, image, or text.


data = webread(url,QueryName1,QueryValue1,...,QueryNameN,QueryValueN) appends 

query parameters to url, as specified by one or more pairs of name-value arguments. 

The web service defines the query parameters.


data = webread(___,options) adds other HTTP request options, specified by the 

weboptions object options

You can use this syntax with any of the input arguments of the previous syntaxes.

To return data as a specific output type, specify the ContentType property of options.

To read content with a function, specify the ContentReader property of options as 

a handle to the function. webread downloads data from a web service and

reads the data with the specified function:

  • 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.

webread supports HTTP GET and POST methods. To send an HTTP POST request, 

specify the RequestMethod property of options as 'post'

Many web services provide both GET and POST methods to request data.

[data,colormap,alpha] = webread(___) reads an image from 

the web service specified by url and returns the image in data

You can use the previous syntaxes to return the image only. 

Use this syntax to return the colormap and alpha channels associated with the image.

webread returns an image when the HTTP response has a Content-Type header field 

that specifies an image media type and if the image format is supported by imread.

For supported image formats, see Supported File Formats for Import and Export.

[data,Fs] = webread(___) reads audio data from the web service specified by url 

and returns the audio data in data. 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 a Content-Type header field 

that specifies an audio media type and if the audio format is supported by audioread. For supported audio formats, see Supported File Formats for Import and Export.

【以上信息来自于互联网】 以下为翻译为中文说明


 webread

RESTful Web service页面中读取内容

PS:REST(Representational State Transfer的缩写)是一种轻量级的Web Services架构风格,其实现和操作明显比SOAPXML-RPC更为简洁,可以完全通过HTTP协议实现,还可以利用缓存Cache来提高响应速 度,性能、效率和易用性上都优于SOAP协议。

语法

data = webread(url)

data = webread(url,QueryName1,QueryValue1,...,QueryNameN,QueryValueN)

data = webread(___,options)

[data,colormap,alpha] = webread(___)

[data,Fs] = webread(___)

说明

data = webread(url)从URL指定的Web服务中读取内容,并返回数据中的内容。

Web服务提供了一个RESTful API,它返回格式为互联网媒体类型(如JSON,XML,图像或文本)的数据。

data = webread(url,QueryName1,QueryValue1,...,QueryNameN,QueryValueN)将查询参数附加到url,由一对或多对名称值参数指定。 Web服务定义查询参数。

ƒdata = webread(___,options)添加了由web options对象选项指定的其他HTTP请求选项。您可以将此语法与先前语法的任何输入参数一起使用。

要以特定的输出类型返回数据,请指定选项的ContentType属性。

要使用函数读取内容,请将该选项的ContentReader属性指定为函数的句柄。 webread从web服务器下载数据并用指定的函数读取数据:

如果指定一个返回多个输出参数的函数的句柄,则webread返回所有输出参数。

如果指定的函数的句柄不返回任何输出参数(如视频文件的Image Processing Toolbox™函数@implay),则webread不返回输出参数。

webread支持HTTP GET和POST方法。要发送HTTP POST请求,请将选项的RequestMethod属性指定为“post”。许多Web服务提供GET和POST方法来请求数据。

④[data,colormap,alpha] = webread(___)从URL指定的Web服务读取图像,并返回数据中的图像。您可以使用以前的语法来仅返回图像。使用此语法返回与图像关联的色彩映射和Alpha通道。

HTTP响应具有指定图像媒体类型的Content-Type头字段,并且imread支持图像格式时,webread返回图像。有关支持的图像格式,请参阅支持的导入和导出格式。

⑤[data,Fs] = webread(___)从URL指定的Web服务读取音频数据,并返回数据中的音频数据。您可以使用以前的语法仅返回音频数据。使用此语法返回以Hz为单位的音频数据采样率。

HTTP响应具有指定音频媒体类型的Content-Type头字段并且audioread支持音频格式时,webread返回音频数据。有关支持的音频格式,请参阅支持的导入和导出格式。

 

 

 

0

阅读 收藏 喜欢 打印举报/Report
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有