instruction: Base instruction class

Description Usage Arguments Value Examples

View source: R/instruction.R

Description

instruction provides the guidelines to chewie scraping by setting all of searching and returning object parameters.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
instruction(
  title,
  path,
  selector = "css",
  alternative_path = NULL,
  parse_as = NULL,
  pattern = NULL
)

instruction_set_result(x, result)

Arguments

title

an arbitrary name to the scraped object

path

a css or xpath path to the object to be scraped

selector

whether path/alternative_path is a css or xpath selector, defaults to NULL

alternative_path

an alternative css or xpath path to the object to be scraped

parse_as

indicates if an extractor should be applied to the resulting scraped item. Currently available extractors are:

  • extract_text

  • extract_numeric

  • extract_table

  • extract_date

  • extract_datetime

  • extract_timedelta

  • extract_price.

pattern

a RegEx pattern to be applied before parsing

Value

a chewie_instruction object

Examples

1
2
3
4
5
6
7
sample_instruction <- instruction(
  title = "price_header",
  selector = "css",
  path = "h1:nth-of-type(1)",
  alternative_path = "h2:nth-of-type(2)",
  parse_as = "text"
)

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