comparison src/DLD-FUNCTIONS/urlwrite.cc @ 6588:4deaf99400b2

[project @ 2007-04-26 20:31:10 by jwe]
author jwe
date Thu, 26 Apr 2007 20:31:10 +0000
parents 5a5a09d7deb8
children 1294fa07652b
comparison
equal deleted inserted replaced
6587:00fad3bad2a5 6588:4deaf99400b2
194 @deftypefnx {Loadable Function} {[@var{f}, @var{success}, @var{message}] =} urlwrite (@var{url}, @var{localfile})\n\ 194 @deftypefnx {Loadable Function} {[@var{f}, @var{success}, @var{message}] =} urlwrite (@var{url}, @var{localfile})\n\
195 Download a remote file specified by its @var{URL} and save it as\n\ 195 Download a remote file specified by its @var{URL} and save it as\n\
196 @var{localfile}. For example,\n\ 196 @var{localfile}. For example,\n\
197 \n\ 197 \n\
198 @example\n\ 198 @example\n\
199 urlwrite ('ftp://ftp.octave.org/pub/octave/README', 'README.txt');\n\ 199 urlwrite (\"ftp://ftp.octave.org/pub/octave/README\", \"README.txt\");\n\
200 @end example\n\ 200 @end example\n\
201 \n\ 201 \n\
202 The full path of the downloaded file is returned in @var{f}. The\n\ 202 The full path of the downloaded file is returned in @var{f}. The\n\
203 variable @var{success} is 1 if the download was successful,\n\ 203 variable @var{success} is 1 if the download was successful,\n\
204 otherwise it is 0 in which case @var{message} contains an error\n\ 204 otherwise it is 0 in which case @var{message} contains an error\n\
205 message. If no output argument is specified and if an error occurs,\n\ 205 message. If no output argument is specified and if an error occurs,\n\
206 then the error is signaled through octave's error handling mechanism.\n\ 206 then the error is signaled through Octave's error handling mechanism.\n\
207 \n\ 207 \n\
208 This function uses libcurl. Curl supports, among others, the HTTP,\n\ 208 This function uses libcurl. Curl supports, among others, the HTTP,\n\
209 FTP and FILE protocols. Username and password may be specified in\n\ 209 FTP and FILE protocols. Username and password may be specified in\n\
210 the URL, for example:\n\ 210 the URL, for example:\n\
211 \n\ 211 \n\
212 @example\n\ 212 @example\n\
213 urlwrite ('http://username:password@@example.com/file.txt', 'file.txt');\n\ 213 urlwrite (\"http://username:password@@example.com/file.txt\",\n\
214 \"file.txt\");\n\
214 @end example\n\ 215 @end example\n\
215 \n\ 216 \n\
216 GET and POST requests can be specified by @var{method} and @var{param}.\n\ 217 GET and POST requests can be specified by @var{method} and @var{param}.\n\
217 The parameter @var{method} is either 'get' or 'post' and @var{param} is a\n\ 218 The parameter @var{method} is either @samp{get} or @get{post}\n\
218 cell array of parameter and value pairs. For example:\n\ 219 and @var{param} is a cell array of parameter and value pairs.\n\
219 \n\ 220 For example:\n\
220 @example\n\ 221 \n\
221 urlwrite ('http://www.google.com/search', 'search.html', 'get', @{'query', 'octave'@});\n\ 222 @example\n\
223 urlwrite (\"http://www.google.com/search\", \"search.html\",\n\
224 \"get\", @{\"query\", \"octave\"@});\n\
222 @end example\n\ 225 @end example\n\
223 @seealso{urlread}\n\ 226 @seealso{urlread}\n\
224 @end deftypefn") 227 @end deftypefn")
225 { 228 {
226 octave_value_list retval; 229 octave_value_list retval;
333 @deftypefnx {Loadable Function} {[@dots{}] =} urlread (@var{url}, @var{method}, @var{param})\n\ 336 @deftypefnx {Loadable Function} {[@dots{}] =} urlread (@var{url}, @var{method}, @var{param})\n\
334 Download a remote file specified by its @var{URL} and return its content\n\ 337 Download a remote file specified by its @var{URL} and return its content\n\
335 in string @var{s}. For example,\n\ 338 in string @var{s}. For example,\n\
336 \n\ 339 \n\
337 @example\n\ 340 @example\n\
338 s = urlread ('ftp://ftp.octave.org/pub/octave/README');\n\ 341 s = urlread (\"ftp://ftp.octave.org/pub/octave/README\");\n\
339 @end example\n\ 342 @end example\n\
340 \n\ 343 \n\
341 The variable @var{success} is 1 if the download was successful,\n\ 344 The variable @var{success} is 1 if the download was successful,\n\
342 otherwise it is 0 in which case @var{message} contains an error\n\ 345 otherwise it is 0 in which case @var{message} contains an error\n\
343 message. If no output argument is specified and if an error occurs,\n\ 346 message. If no output argument is specified and if an error occurs,\n\
344 then the error is signaled through octave's error handling mechanism.\n\ 347 then the error is signaled through Octave's error handling mechanism.\n\
345 \n\ 348 \n\
346 This function uses libcurl. Curl supports, among others, the HTTP,\n\ 349 This function uses libcurl. Curl supports, among others, the HTTP,\n\
347 FTP and FILE protocols. Username and password may be specified in the\n\ 350 FTP and FILE protocols. Username and password may be specified in the\n\
348 URL. For example,\n\ 351 URL. For example,\n\
349 \n\ 352 \n\
350 @example\n\ 353 @example\n\
351 s = urlread ('http://username:password@@example.com/file.txt');\n\ 354 s = urlread (\"http://username:password@@example.com/file.txt\");\n\
352 @end example\n\ 355 @end example\n\
353 \n\ 356 \n\
354 GET and POST requests can be specified by @var{method} and @var{param}.\n\ 357 GET and POST requests can be specified by @var{method} and @var{param}.\n\
355 The parameter @var{method} is either 'get' or 'post' and @var{param} is a\n\ 358 The parameter @var{method} is either @samp{get} or @samp{post}\n\
356 cell array of parameter and value pairs. For example,\n\ 359 and @var{param} is a cell array of parameter and value pairs.\n\
357 \n\ 360 For example,\n\
358 @example\n\ 361 \n\
359 s = urlread ('http://www.google.com/search', 'get', @{'query', 'octave'@});\n\ 362 @example\n\
363 s = urlread (\"http://www.google.com/search\", \"get\",\n\
364 @{\"query\", \"octave\"@});\n\
360 @end example\n\ 365 @end example\n\
361 @seealso{urlwrite}\n\ 366 @seealso{urlwrite}\n\
362 @end deftypefn") 367 @end deftypefn")
363 { 368 {
364 // octave's return value 369 // Octave's return value
365 octave_value_list retval; 370 octave_value_list retval;
366 371
367 #if defined (HAVE_CURL) 372 #if defined (HAVE_CURL)
368 373
369 int nargin = args.length (); 374 int nargin = args.length ();