as.list.selenider_elements | R Documentation |
This function essentially turns x
into:
list(x[[1]], x[[2]], ...)
However, to do this, the length of x
must be computed. This means that
while each element inside the list is still lazy, the list itself cannot be
considered lazy, since the number of elements in the DOM may change. To
avoid problems, it is recommended to use an element list just after it is
created, to make sure the list is an accurate representation of the DOM
when it is being used.
## S3 method for class 'selenider_elements'
as.list(x, timeout = NULL, ...)
x |
A |
timeout |
How long to wait for |
... |
Not used. |
Transform a selenider_elements
object into a list of
selenider_element
objects. The result can then be used in for loops and
higher order functions like lapply()
/purrr::map()
(whereas a
selenider_element
object cannot).
A list of selenider_element
objects.
elem_flatten()
to combine multiple
selenider_element
/selenider_elements
objects into a single object.
find_each_element()
and find_all_elements()
to select elements
using an element collection while preserving laziness.
html <- "
<div id='div1'>
<p>Text 1</p>
</div>
<div id='div2'>
<p>Text 2</p>
</div>
<div id='div3'>
<p>Text 3</p>
</div>
<div id='div4'>
<p>Text 4</p>
</div>
"
session <- minimal_selenider_session(html)
p_tags <- ss("p")
for (elem in as.list(p_tags)) {
print(elem_text(elem))
}
p_tags |>
as.list() |>
lapply(elem_text)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.