Description Usage Arguments Details Value Author(s) References See Also Examples
Send DOM requests to a web page to modify the web page content and/or access existing web page content.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | createElement(pageID, tagName, response=nodePtr(),
async = FALSE, callback = NULL, tag = getRequestID())
createElementNS(pageID, namespace, tagName, response=nodePtr(),
async = FALSE, callback = NULL, tag = getRequestID())
## S4 method for signature 'numeric,DOM_node,missing'
appendChild(pageID, child, parent, response=htmlNode(),
ns = FALSE, async = FALSE, callback = NULL, tag = getRequestID())
## S4 method for signature 'numeric,DOM_node,DOM_node_ref'
appendChild(pageID, child, parent, response=htmlNode(),
ns = FALSE, async = FALSE, callback = NULL, tag = getRequestID())
## S4 method for signature 'numeric,DOM_node_ref,missing'
removeChild(pageID, child, parent, response=htmlNode(),
async = FALSE, callback = NULL, tag = getRequestID())
## S4 method for signature 'numeric,DOM_node_ref,DOM_node_ref'
removeChild(pageID, child, parent, response=htmlNode(),
async = FALSE, callback = NULL, tag = getRequestID())
## S4 method for signature 'numeric,DOM_node,DOM_node_ref,missing'
replaceChild(pageID, newChild, oldChild, parent, response=htmlNode(),
ns = FALSE, async = FALSE, callback = NULL, tag = getRequestID())
## S4 method for signature 'numeric,DOM_node,DOM_node_ref,DOM_node_ref'
replaceChild(pageID, newChild, oldChild, parent, response=htmlNode(),
ns = FALSE, async = FALSE, callback = NULL, tag = getRequestID())
## S4 method for signature 'numeric,DOM_node_ref,character'
getAttribute(pageID, elt,
attrName, response = NULL,
async = FALSE, callback = NULL, tag = getRequestID())
## S4 method for signature 'numeric,DOM_node_ref,character,character'
setAttribute(pageID, elt, attrName, attrValue,
async = FALSE, callback = NULL, tag = getRequestID())
## S4 method for signature 'numeric,character'
getElementById(pageID, id, response=htmlNode(),
async = FALSE, callback = NULL, tag = getRequestID())
## S4 method for signature 'numeric,character'
getElementsByTagName(pageID, name, response=htmlNode(),
async = FALSE, callback = NULL, tag = getRequestID())
## S4 method for signature 'numeric,character,missing'
getElementsByClassName(pageID, name, root, response=htmlNode(),
async = FALSE, callback = NULL, tag = getRequestID())
## S4 method for signature 'numeric,character,DOM_node_ref'
getElementsByClassName(pageID, name, root, response=htmlNode(),
async = FALSE, callback = NULL, tag = getRequestID())
## S4 method for signature 'numeric,DOM_node_ref'
click(pageID, elt, callback = NULL, tag
= getRequestID())
## S4 method for signature 'numeric,DOM_obj_ref,character'
getProperty(pageID, object,
propName, response = NULL,
async = FALSE, callback = NULL, tag = getRequestID())
## S4 method for signature 'numeric,DOM_obj_ref,character,DOM_obj_ref'
setProperty(pageID, object,
propName, value, warn = TRUE,
async = FALSE, callback = NULL, tag = getRequestID())
## S4 method for signature 'numeric,DOM_obj_ref,character,DOM_value'
setProperty(pageID, object,
propName, value, warn = TRUE,
async = FALSE, callback = NULL, tag = getRequestID())
styleSheets(pageID, async=FALSE, callback=NULL, tag=getRequestID())
## S4 method for signature 'numeric,DOM_CSSStyleSheet_ptr,character,numeric'
insertRule(pageID, styleSheet, rule, index,
async = FALSE, callback = NULL, tag = getRequestID())
## S4 method for signature 'numeric,DOM_CSSStyleSheet_ptr,numeric'
deleteRule(pageID, styleSheet, index,
async = FALSE, callback = NULL, tag = getRequestID())
## S4 method for signature 'numeric,DOM_CSSStyleDeclaration_ptr,character'
removeProperty(pageID, style, propName, response = NULL,
async = FALSE, callback = NULL, tag = getRequestID())
## S4 method for signature 'numeric,DOM_CSSStyleDeclaration_ptr'
propertyNames(pageID, style,
async = FALSE, callback = NULL, tag = getRequestID())
|
pageID |
A page identifier, as returned by, e.g., |
tagName |
A character value describing an HTML (or SVG) tag name. |
namespace |
A character value describing a valid namespace
(e.g., |
child |
A DOM node representation, e.g., the result from |
parent |
A DOM node representation for an existing node (e.g., the result from
|
newChild |
A DOM node representation, e.g., the result from |
oldChild |
A DOM node representation for an existing node (e.g., the result from
|
elt |
A DOM node representation for an existing node (e.g., the result from
|
object |
A DOM object representation for an existing node (e.g., the result
from |
propName |
A character value specifying a DOM object property name. |
value |
A DOM object representation for an existing node (or a simple numeric, character, or logical value. |
response |
A DOM node representation that provides a template for the return
value, e.g., |
id |
A character value specifying an element id attribute. |
name |
A character value specifying a tag name (or ‘*’) or a class name (or several class names separated by spaces). |
root |
A DOM node representation for an existing node (e.g., the result from
|
attrName |
The attribute name. |
attrValue |
The attribute value (will be coerced to a character value). |
styleSheet |
A DOM node representation for an existing style sheet. |
style |
A DOM node representation for an existing style declaration. |
rule |
A character value describing a CSS rule. |
index |
A numeric index describing the location of the rule within the stylesheet. |
ns |
A namespace for the child element that is to be created.
Valid values are |
warn |
A logical indicating whether to emit warning messages if we try to set a read-only property. |
async |
A logical indicating whether the request is asynchronous. |
callback |
A function to be called when the DOM request has been fulfilled. |
tag |
A unique request identifier. |
These functions implement (some of) the basic DOM interface to web page content.
appendChild
adds a new element, child
, to the
page as a child of an existing element, parent
, or
it adds an existing element, child
, to parent
.
removeChild
removes an existing element. If
parent
is NULL
, the parent is implicit, but it is
also possible to explicitly specify the parent. In the latter case,
it is possible for the request to fail (because the specified parent
and child are not actually related in the page).
replaceChild
replaces an existing element. The
new element is a new element, newChild
, or an existing
element, newChild
. In the latter case, the new element is
moved from its old position to the new position.
If parent
is NULL
, the parent is implicit, but it is
also possible to explicitly specify the parent.
click
sends a click event to an element, elt
.
For adding SVG content within HTML, you should
specify ns="SVG"
and for adding
HTML content within SVG, you should specify ns="HTML"
.
If async
is FALSE
, the request is synchronous and R
blocks until the browser has sent a response.
Otherwise, the request is asynchronous and control is returned to
the command line.
If callback
is non-NULL
, it will be run
when the browser responds. The callback
function will be called with a single
argument, which will contain the response from the web browser
(see the Value section below).
The callback
can contain further requests, but they must
be asynchronous requests.
A click
is always asynchronous (the request may be
fulfilled in R before the browser has completed handling the click
event); this function is aimed at debugging with a headless browser.
Most functions return a DOM node,
which could be, e.g., HTML or CSS, depending on the response
argument.
For createElement
, the default is to return a
DOM_note_ptr
object (because the element created is not
part of the document, so cannot be identified from R any other way).
For appendChild
, the child element that was added.
For removeChild
, the child element that was removed.
For replaceChild
, the old child element that was
replaced.
For getElementById
, getElementsByTagName
, and
getElementsByClassName
, the matching elements.
Both setAttribute
and click
return NULL
.
Paul Murrell
1 2 3 | headlessPage <- htmlPage(client=phantomClient)
appendChild(headlessPage, htmlNode("<p>test</p>"))
closePage(headlessPage)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.