html_source: HTML source object

Description Usage Format Fields Methods Note See Also

Description

This objects represent the basic set of data needed for defining a projection source with HTML data. It is an extesnsion of the projection_source object with some specific fields and methods related to scraping HTML data.

Usage

1

Format

An R6 class object.

Fields

table_css

A string with a CSS selector identifying the HTML <table> element holding the projection data.

pid_css

A string with a CSS selector idenfitying the HTML node holding the player id if available

rm_elem

A character vector of CSS selectors identifying HTML nodes to remove for successful scraping of the table.

index

If table_css does not uniquely identify the table, use this field to identify the index number for the table in the list of nodes. If multiple numbers are specified then the tables are ssume to have identical number of rows and will be combined with bind_cols

extract_pid

A function that will take the HTML node holding the player id and extract the specific player_id

split_cols

A list with each element being a list representing input to either separate or extract. Each input element should be in the format of a function of position to allow for different handling of fields for different positions. See the projection_sources object for predefined sources.

recode_cols

a list with each element being a list representing names of columns to be recoded and a named vector for each column holding the recode values to be used by recode.

Methods

open_session

Takes season, week, position as input and and opens a session on the website via the html_session function after determining the URL

close_session

Closes the session that is currently open

get_table

Retrieves the table from the session without any spliltting of columns defined in split_cols, any recoding as defined in recode_cols or any renaming based on stat_cols

scrape

Scrapes data from the table specified and wrangles the columns based on split_cols, recode_cols and stat_cols

Note

See https://www.w3schools.com/cssref/css_selectors.asp for details on defining CSS selectors

See Also

Other source-class: json_source, projection_source, xlsx_source


MrDAndersen/ffwebscrape documentation built on May 22, 2019, 1:51 p.m.