urlwrite
is not recommended. Use instead.
Description
example
reads web content at the specified and saves it to the file specified by .
stores the file path in variable , and suppresses the display of error messages, using any of the input arguments in the previous syntaxes. When the operation is successful, is . Otherwise, is .
Examples
collapse all
Download Web Content by Specifying Complete URL
Download the HTML for the page on the MATLAB Central File Exchange that lists submissions related to . Save the results to in the current folder.
View the file.
Download Web Content Related to Term
Download the HTML for the page on the MATLAB Central File Exchange that lists submissions related to . Save the results to in the current folder.
downloads the HTML content from and writes it to .
Download content from a page on the MATLAB Central File Exchange as in the first example, and specify a timeout duration of 5 seconds.
Input Arguments
collapse all
Content location
character vector
Content location, specified as a character vector. Include the transfer protocol, such as , , or .
Example:
Name of file to store web content
character vector
Name of the file to store the web content, specified as a character vector. If you do not specify the path for , saves the file in the current folder.
Example:
Name-Value Pair Arguments
Specify optional comma-separated pairs of arguments. is the argument name and is the corresponding value. must appear inside quotes. You can specify several name and value pair arguments in any order as .
Example: specifies that should time out after 10 seconds, and the character encoding of the file is UTF Data to send to the web form using the GET method
cell array
Parameters of the data to send to the web form using the GET method, specified as the comma-separated pair consisting of and a cell array of paired parameter names and values. The supported parameters depend upon the URL.
includes the data in the URL, separated by and characters.
Example:
Data to send to the web form using the POST method
cell array
Parameters of the data to send to the web form using the POST method, specified as the comma-separated pair consisting of and a cell array of paired parameter names and values. The supported parameters depend upon the URL.
submits the data as part of the request headers, not explicitly in the URL.
Character encoding
character vector
Character encoding, specified as the comma-separated pair consisting of and a character vector. If you do not specify , the function attempts to determine the character encoding from the headers of the file. If the character encoding cannot be determined, defaults to the native encoding for the file protocol, and UTF-8 for all other protocols.
Example:
Timeout duration
scalar
Timeout duration in seconds, specified as the comma-separated pair consisting of and a scalar. The timeout duration determines when the function errors rather than continues to wait for the server to respond or send data.
Example:
Client user agent identification
character vector
Client user agent identification, specified as the comma-separated pair consisting of and a character vector.
Example:
HTTP authentication mechanism
HTTP authentication mechanism, specified as the comma-separated pair consisting of and a character vector. Currently, only the value is supported. specifies basic authentication.
If you include the argument, you must also include the and arguments.
User identifier
character vector
User identifier, specified as the comma-separated pair consisting of and a character vector. If you include the argument, you must also include the and arguments.
Example:
User authentication password
character vector
User authentication password, specified as the comma-separated pair consisting of and a character vector. If you include the argument, you must also include the and arguments.
Example:
Output Arguments
collapse all
Path of the file
character vector
Path of the file specified by , returned as a character vector.
Download status
|
Download status, returned as either or . When the download is successful, is . Otherwise, is .
Tips
and can download content from FTP sites. Alternatively, use the function to connect to an FTP server and the function to download a file.
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
Select web siteYou can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Contact your local office
0 thoughts to “Download a file from a site using the url”