get_element {parsel}R Documentation

wrapper around getElementText() method to generate safe scraping code

Description

wrapper around getElementText() method to generate safe scraping code

Usage

get_element(using, value, name = NULL, multiple = FALSE, prev = NULL)

Arguments

using

character string specifying locator scheme to use to search elements. Available schemes: "class name", "css selector", "id", "name", "link text", "partial link text", "tag name", "xpath".

value

character string specifying the search target.

name

character string specifying the object name the RSelenium "wElement" class object should be saved to. If NULL a name will be generated automatically.

multiple

logical indicating whether multiple elements should be returned. If TRUE the findElements() method will be invoked.

prev

a placeholder for the output of functions being piped into get_element(). Defaults to NULL and should not be altered.

Value

a character string defining 'RSelenium' getElementText() instructions that can be pasted into a scraping function.

Examples

## Not run: 

#navigate to wikipedia, type "Hello" into the search box,
#press enter, get page header

parsel::go("https://www.wikipedia.org/") %>>%
parsel::type(using = "id",
             value = "'searchInput'",
             name = "searchbox",
             text = c("Hello","\uE007")) %>>%
parsel::get_element(using = "id",
                    value = "'firstHeading'",
                    name = "header") %>>%
            show()

#navigate to wikipedia, type "Hello" into the search box, press enter,
#get page header, save in external data.frame x.

parsel::go("https://www.wikipedia.org/") %>>%
parsel::type(using = "id",
             value = "'searchInput'",
             name = "searchbox",
             text = c("Hello","\uE007")) %>>%
parsel::get_element(using = "id",
                    value = "'firstHeading'",
                    name = "x[,1]") %>>%
                    show()


## End(Not run)

[Package parsel version 0.3.0 Index]