URLFetch

URLFetch["url"]
returns the contents of a URL as a string.

URLFetch["url", elements]
returns the specified elements from a URL.

Details and OptionsDetails and Options

  • Types of elements supported:
  • "Content"a string of the URL's content
    "ContentData"a list of bytes of the URL's content
    "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:
  • elemreturn 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 used when connecting to an HTTP server
    "Parameters"{}parameters to be sent to the HTTP server
    "VerifyPeer"Trueverify the authenticity of a remote server using SSL certificates
    "Username"""connect to an HTTP server with a certain username
    "Password"""connect to an HTTP server with a certain password
    "UserAgent"Automaticchange the user agent sent to an HTTP server
    "Cookies"Automaticcookie management is Automatic or may be handled manually by passing a list of cookies
    "StoreCookies"Trueif True, cookies will be stored in a global cookie share
    "Headers"{}headers to be manually sent to the HTTP server
    "BodyData"""contents of message body to be sent to the server
    "MultipartData"{}to upload multipart data, each part must be of the form , where {bytes} is a list of bytes
    "ReadTimeout"0the maximum allowed time in seconds to download or upload data to the server
    "ConnectTimeout"0the maximum allowed time in seconds to connect to the server

ExamplesExamplesopen allclose all

Basic Examples (3)Basic Examples (3)

This returns the content of the URL:

In[1]:=
Click for copyable input
In[2]:=
Click for copyable input
Out[2]=

Passing data to the server:

In[1]:=
Click for copyable input

Gather information about a connection:

In[1]:=
Click for copyable input
Out[1]=
New in 9
New to Mathematica? Find your learning path »
Have a question? Ask support »