文档

urlwrite

Download URL content and save to file (not recommended)

urlwrite不建议。利用Websave反而。

句法

urlwrite(url,文件名)
urlwrite(url,文件名,名称,值)
[filest,状态] = urlwrite(___

描述

例子

urlwrite(URL,,,,文件名在指定的URLand saves it to the file specified by文件名

例子

urlwrite(URL,,,,文件名,,,,名称,价值uses additional options specified by one or more名称,价值pair arguments.

[[申报人,,,,地位] = urlwrite(___stores the file path in variable申报人,并使用上一个语法中的任何输入参数抑制错误消息的显示。当操作成功时地位1。Otherwise,地位0

例子

全部收缩

Download the HTML for the page on the MATLAB® Central File Exchange that lists submissions related tourlwrite。保存结果samples.html在当前文件夹中。

fullurl = ['//www.tianjin-qmedu.com/matlabcentral/fileexchange'...'?term=urlwrite'];文件名='samples.html';urlwrite(fullurl,文件名);

查看文件。

web(filename)

Download the HTML for the page on the MATLAB® Central File Exchange that lists submissions related tourlwrite。保存结果samples.html在当前文件夹中。

URL='//www.tianjin-qmedu.com/matlabcentral/fileexchange';文件名='samples.html';urlwrite(URL,,,,文件名,,,,'得到',,,,{'学期',,,,'urlwrite'});

urlwrite从中下载HTML内容//www.tianjin-qmedu.com/matlabcentral/fileexchange/?term=urlwriteand writes it tosamples.html

如第一个示例中,从MATLAB®中央文件交换的页面下载内容,并指定5秒钟的超时持续时间。

fullurl = ['//www.tianjin-qmedu.com/matlabcentral/fileexchange'...'?term=urlwrite'];文件名='samples.html';urlwrite(fullURL,filename,'暂停',5);

输入参数

全部收缩

Content location, specified as a character vector. Include the transfer protocol, such ashttp,,,,ftp, 或者文件

Example:'//www.tianjin-qmedu.com/matlabcentral'

存储Web内容的文件的名称,指定为字符向量。如果您不指定路径文件名,,,,urlwrite将文件保存在当前文件夹中。

Example:'myfile.html'

名称值对参数

指定可选的逗号分隔对名称,价值arguments.姓名是参数名称和Value是the corresponding value.姓名must appear inside single quotes ('')。您可以按任何顺序指定几个名称和值对参数姓名1,,,,Value1,...,NameN,ValueN

Example:'暂停',,,,10,,,,'charset',,,,'UTF-8'指定urlread应该在10秒后超时,并且文件的字符编码为UTF-8。

全部收缩

使用GET方法将数据的参数发送到Web表单,该方法指定为逗号分隔对'得到'and a cell array of paired parameter names and values. The supported parameters depend upon the URL.

'得到'包括URL中的数据,分开and人物。

Example:'得到',,,,{'term','urlread'}

数据参数使用邮政方法发送到Web表单,该方法指定为逗号分隔对'邮政'and a cell array of paired parameter names and values. The supported parameters depend upon the URL.

'邮政'将数据作为请求标头的一部分提交,而不是在URL中明确提交。

字符编码,,,,specified as the comma-separated pair consisting of'charset'和角色向量。如果您不指定charset,,,,the function attempts to determine the character encoding from the headers of the file. If the character encoding cannot be determined,charsetdefaults to the native encoding for the file protocol, and UTF-8 for all other protocols.

Example:'charset','ISO-8859-1'

超时持续时间为几秒钟,指定为逗号分隔对'暂停'和标量。超时持续时间确定功能何时错误而不是继续等待服务器响应或发送数据。

Example:'暂停',,,,10

客户用户代理标识,指定为逗号分隔对'UserAgent'和角色向量。

Example:'UserAgent','MATLAB R2012b'

HTTP身份验证机制,指定为逗号分隔对'验证'和角色向量。Currently, only the value'Basic'是supported.“身份验证”,“基本”指定基本身份验证。

如果您包括Authentication论点,您还必须包括用户名and密码arguments.

用户标识符,指定为逗号分隔对'用户名'和角色向量。如果您包括用户名论点,您还必须包括密码andAuthenticationarguments.

Example:'用户名',,,,'myName'

用户身份验证密码,指定为逗号分隔对'Password'和角色向量。如果您包括密码论点,您还必须包括用户名andAuthenticationarguments.

Example:“密码”,'mypassword123'

输出参数

全部收缩

文件指定的路径文件名,作为角色向量返回。

Download status, returned as either1or0。When the download is successful,地位1。Otherwise,地位0

Tips

  • urlreadandurlwritecan download content from FTP sites. Alternatively, use theftp连接到FTP服务器和mget功能下载文件。

Introduced before R2006a

Was this topic helpful?