README.md

About

Shrip is life.

Install

devtools::install_github('chebuu/shrip')

Documentation

help("shrip")

Usage

library(shrip)
library(xml2)

# Define:

PAGE_BASE <- NULL # Base url to iterate
FILE_BASE <- NULL # Base url to iterate
XPATH_PAGES <- list( # XPath queries
  '//div[2]/header[1]/em' = xml2::xml_find_all
)
XPATH_FILES <- list( # XPath queries
  '//div[1]/div[1]/strong[1]/a' = xml2::xml_find_first,
  '//div[1]/div[2]/strong[1]/a[1]' = xml2::xml_find_first,
  '//div[1]/div[2]/strong[1]/a[2]' = xml2::xml_find_first
)

myIter <- function(res, xpath) lapply(
    names(xpath), 
    function(xp) {
      xml2::xml_txt(
        XPATH_PAGES[[xp]]
          (content(res, 'parsed'), xp)
      )
    }
  )

cbPages <- function(res) {
  unlist(
    myIter(res, XPATH_PAGES)
  )
}

cbFiles <- function(res) {
  unlist(
    myIter(res, XPATH_PAGES)
  )
}

# Run:
shrip::rip(1:10, cbPages, cbFiles)

Config file

You don't have this.

# source("<theconfigfile>.R")
help('Shrip Help','shrip')


Chebuu/shrip documentation built on July 19, 2020, 12:33 a.m.