getHTMLFormDescription | R Documentation |
This function is used to read and process an HTML document
(either from the file system or via HTTP/FTP)
and extract descriptions of the <FORM> elements
it contains. Each form is collected into
an object of class HTMLFormDescription
that describes the method for submitting
the form (POST or GET), the URL for the submission,
and the elements within the form.
These descriptions can be used
to mimic the form via functions (or GUIs) within R and validate values
being submitted to forms.
getHTMLFormDescription(url, dropButtons = TRUE, ..., baseURL = docName(doc))
getHTMLFormDescriptionViaHandlers(url, ..., multi = TRUE, handlers)
url |
the URI for the HTML document. If this is a local file, there is no need for |
... |
arguments that are passed directly to |
dropButtons |
a logical value indicating whether to omit button elements in the form description. These are typically Submit or Reset buttons that are not relevant for submitting the form request from R. |
baseURL |
the URL of the HTML form. This is used to compute relative URLs for the code associated with the form. |
multi |
a logical value indicating whether to use the handlers
that deal with multiple forms within the document
or ( |
handlers |
a collection of functions that are passed
to |
If handlers
is provided by the caller
and is not an object of class HTMLFormParser
with a values
function element, then the
handlers
object is returned.
The caller is supposed to know how to extract the information.
Otherwise, if handlers
is a HTMLMultiFormParser
object, a list of
HTMLFormDescriptions
is returned.
The names of the elements in the list are taken from
the names of the individual forms, if available.
If multi
is not specified and there is only a single
form in the document, just that description object is returned.
This simplifies accessing the elements.
If this is not desired, specify multi = TRUE
explicitly to have a list returned.
If multi
is given the value FALSE
,
the HTMLFormParser
is used and a single
object of class HTMLFormDescription
is returned.
In either case, if the handlers are instructed to check
for a dynamic form (checkDynamic
), if
any of the elements have a onChange
attribute, the form is submitted with
the different options for that element and
a description of the possible values for all the elements
that corresponding to these different settings is included
in the result in the dynamicElements
field.
This allows us to handle simple dynamic forms whose possible
element values (but not entire structure) change when
one element's value is selected. See the species field
in the wormbase form for a simple example.
Duncan Temple Lang <duncan@wald.ucdavis.edu>
multiFormElementHandlers
formElementHandlers
htmlTreeParse
if(require(RCurl) && require(XML)) {
txt = getURLContent("http://www.google.com")
doc = htmlParse(txt, asText = TRUE)
f = getHTMLFormDescription(doc)
}
eq = getHTMLFormDescription("http://neic.usgs.gov/neis/epic/epic_global.html")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.