URLSave

URLSave is being phased out in favor of URLDownload, which was introduced experimentally in Version 11.

URLSave["url"]

saves the content of the URL to a file in $TemporaryDirectory.

URLSave["url","file"]

saves the content of the URL to a file.

URLSave["url","file",elements]

returns the specified elements from a URL.

Details and Options

  • Types of elements supported:
  • "Headers"a list of all headers received from the URL
    "Cookies"a list of all known cookies
    "StatusCode"the status code returned by the server
  • The following forms of element specifications can be given:
  • "elem"return a single element
    {elem1,elem2,}return several elements
    {"Rules",{elem1,elem2,}}return several elements as a list of rules
    "Rules"return all possible elements as a list of rules
    "All"return all possible elements as a list
  • The following options can be given:
  • Method"GET"method to use for request
    "Parameters"{}parameters to be sent for the request
    "Body"""contents of message body to be sent
    "MultipartElements"{}list of multipart data elements to send
    "Username"""username to use for the request
    "Password"""password to use for the request
    "Headers"{}headers to be manually sent to the HTTP server
    "Cookies"Truecookies to pass to the server
    "StoreCookies"Automaticwhether to store received cookies
    "VerifyPeer"Trueverify authenticity using SSL certificates
    "UserAgent"Automaticuser agent string to send
    "ReadTimeout"0time to allow for uploading or downloading data
    "ConnectTimeout"0time to allow for connecting to the server
    BinaryFormatTruewhether to avoid textual interpretation of newlines or other data
    "FollowRedirects"Truewhether to follow redirects

Examples

open allclose all

Basic Examples  (3)

This saves the content of the URL:

Download a file and check the status code returned from the server:

Gather information about a connection:

Options  (13)

"Method"  (1)

"Method" can be used to specify the HTTP method used by the connection:

"Parameters"  (1)

Specify the parameters that should be sent to the server:

"VerifyPeer"  (1)

Verify that the SSL certificate used by the server is valid:

"Username"  (1)

Specify the username that should be sent to the server:

"Password"  (1)

Specify the password that should be sent to the server:

"UserAgent"  (1)

Specify the user agent that should be sent to the server:

"Cookies"  (1)

Manually control the cookies used by URLSave:

"StoreCookies"  (1)

If False, "StoreCookies" will not place any new cookies found while connecting to the site in the global cookie share:

"Headers"  (1)

Specify headers to be sent to the server:

"BodyData"  (1)

Specify the message body that should be sent when connecting to the server:

"MultipartData"  (1)

Specify the contents of a multipart message body:

"ReadTimeout"  (1)

Specify the maximum allotted time in seconds to finish downloading data from the server:

"ConnectTimeout"  (1)

Specify the maximum allotted time in seconds to establish a connection to the server:

Properties & Relations  (2)

Use URLFetch to load the content directly into the Wolfram Language:

Use Get for loading Wolfram Language expressions directly over HTTP:

Introduced in 2012
 (9.0)