find_elements: Find elements in a parsed HTML page

Description Usage Arguments Value Examples

View source: R/extractors.R

Description

find_elements scrapes a HTML page using rvest::html_elements and paths described in a chewie_instruction object. If path argument in instruction doesn't find any results it will automatically switch to an alternative_path if it is described in instruction as well.

Usage

1

Arguments

page

a xml_document object

instruction

a chewie_instruction object

Value

correspondent xml_node or xml_nodeset of the described path/ alternative_path

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
## Not run: 
sample_instruction <- instruction(
  title = "price_header",
  path = "h1:nth-of-type(1)",
  selector = "css",
  alternative_path = "h2:nth-of-type(2)",
  parse_as = "text"
)

sample_page <- rvest::read_html(response)

results <- find_elements(sample_page, sample_instruction)

## End(Not run)

leonardodiegues/chewie documentation built on Dec. 21, 2021, 10:41 a.m.