-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathurlread_General.m
More file actions
36 lines (33 loc) · 1.25 KB
/
urlread_General.m
File metadata and controls
36 lines (33 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
function [s,status] = urlread_General(url,varargin)
%URLREAD Returns the contents of a URL as a string.
% S = URLREAD('URL') reads the content at a URL into a string, S. If the
% server returns binary data, the string will contain garbage.
%
% S = URLREAD('URL','method',PARAMS) passes information to the server as
% part of the request. The 'method' can be 'get', or 'post' and PARAMS is a
% cell array of param/value pairs.
%
% S = URLREAD(...,'Timeout',T) sets a timeout, in seconds, when the function
% will error rather than continue to wait for the server to respond or send
% data.
%
% [S,STATUS] = URLREAD(...) catches any errors and returns 1 if the file
% downloaded successfully and 0 otherwise.
%
% Examples:
% s = urlread('http://www.mathworks.com')
% s = urlread('ftp://ftp.mathworks.com/README')
% s = urlread(['file:///' fullfile(prefdir,'history.m')])
%
% From behind a firewall, use the Preferences to set your proxy server.
%
% See also URLWRITE.
% Matthew J. Simoneau, 13-Nov-2001
% Copyright 1984-2011 The MathWorks, Inc.
% Do we want to throw errors or catch them?
if nargout == 2
catchErrors = true;
else
catchErrors = false;
end
[s,status] = urlreadwrite_General(mfilename,catchErrors,url,varargin{:});