postForm                package:RCurl                R Documentation

_S_u_b_m_i_t _a_n _H_T_M_L _f_o_r_m

_D_e_s_c_r_i_p_t_i_o_n:

     These functions provide facilities for submitting an HTML form
     using either the simple GET mechanism (appending the name-value
     pairs of parameters in the URL) or the POST method which puts the
     name-value pairs as separate sections  in the body of the  HTTP
     request. The choice of action is defined by the form, not the
     caller.

_U_s_a_g_e:

     postForm(uri, ..., .params = list(), .opts = curlOptions(url = uri), curl = getCurlHandle())
     getForm(uri, ..., .params = character(), curlOptions = list(), curl = getCurlHandle())

_A_r_g_u_m_e_n_t_s:

     uri: the full URI to which the form is to be posted. This includes
          the host and the specific file or script which will process
          the form.

     ...: the name-value pairs of parameters. Note that these are not
          the CURL options.

 .params: instead of specifying the name-value parameters in "free"
          form via the ... argument, one can specify them as named list
          or character vector. 

   .opts: an object representing the CURL options for this call.

    curl: the 'CURLHandle' object created earlier if one is reusing
          these objects. Otherwise, a new one is generated and
          discarded.

curlOptions: same as .opts but with a different name! This may change.

_D_e_t_a_i_l_s:

     Creating a new 'CURLHandle' allows the C-level code to more
     efficiently map the R-level values to their C equivalents needed
     to make the call. However, reusing the handle across calls can be
     more efficient in that the connection to a server can be
     maintained and thus, the sometimes expensive task of establishing
     it is avoided in subsequent calls.

_V_a_l_u_e:

     By default, the text from the HTTP response is returned.

_S_e_e _A_l_s_o:

     'getURL' 'curlOptions' 'curlSetOpt'

_E_x_a_m_p_l_e_s:

        # Two ways to submit a query to google. Searching for RCurl
       getURL("http://www.google.com/search?hl=en&lr=&ie=ISO-8859-1&q=RCurl&btnG=Search")

        # Here we let getForm do the hard work of combining the names and values.
       getForm("http://www.google.com/search", hl="en", lr="", ie="ISO-8859-1",  q="RCurl", btnG="Search")

        # And here if we already have the parameters as a list/vector.
       getForm("http://www.google.com/search", .params = c(hl="en", lr="", ie="ISO-8859-1",  q="RCurl", btnG="Search"))

        # Now looking at POST method for forms.
       postForm("http://www.speakeasy.org/~cgires/perl_form.cgi",
                 "some_text" = "Duncan",
                 "choice" = "Ho",
                 "radbut" = "eep",
                 "box" = "box1, box2"
               )

       # Genetic database via the Web.
      x = postForm('http://www.wormbase.org/db/searches/advanced/dumper',
              species="briggsae",
              list="",
              flank3="0",
              flank5="0",
              feature="Gene Models",
              dump = "Plain TEXT",
              orientation = "Relative to feature",
              relative = "Chromsome",
              DNA ="flanking sequences only",
              .cgifields = paste(c("feature", "orientation", "DNA", "dump","relative"), collapse=", "))

      # Note that we don't have to paste multiple values together ourselves,
      # e.g. the .cgifields can be specified as a character vector rather
      # than a string.
      x = postForm('http://www.wormbase.org/db/searches/advanced/dumper',
              species="briggsae",
              list="",
              flank3="0",
              flank5="0",
              feature="Gene Models",
              dump = "Plain TEXT",
              orientation = "Relative to feature",
              relative = "Chromsome",
              DNA ="flanking sequences only",
              .cgifields =c("feature", "orientation", "DNA", "dump", "relative"))

               

