diff --git a/.travis.yml b/.travis.yml index 756c505..a88a792 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,17 +9,11 @@ services: env: global: - NOT_CRAN=true - matrix: - - PIP="pip" RETICULATE_PYTHON="/usr/bin/python" - - PYTHON=3 PIP="pip3" RETICULATE_PYTHON="/usr/bin/python3" before_install: - - docker pull scrapinghub/splash:3.0 - - docker run -p 5023:5023 -p 8050:8050 -p 8051:8051 -d scrapinghub/splash:3.0 + - docker pull scrapinghub/splash:3.2 + - docker run -p 5023:5023 -p 8050:8050 -p 8051:8051 -d scrapinghub/splash:3.2 - docker ps -a - - sudo apt-get -y install python${PYTHON}-pip python-dev python${PYTHON}-numpy - - sudo $PIP install -U setuptools - - sudo $PIP install -U docker r: - oldrel diff --git a/NAMESPACE b/NAMESPACE index 827beec..bcfdc0a 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -5,6 +5,7 @@ S3method(as.data.frame,harentries) S3method(as.data.frame,harentry) S3method(print,splash_debug) S3method(print,splash_json) +S3method(print,splashr) export("%>%") export(HARviewer) export(HARviewerOutput) @@ -77,11 +78,16 @@ export(splash_version) export(splash_wait) export(start_splash) export(stop_splash) +export(ua_android_samsung) +export(ua_apple_tv) +export(ua_chromecast) export(ua_ios_safari) +export(ua_kindle) export(ua_linux_chrome) export(ua_linux_firefox) export(ua_macos_chrome) export(ua_macos_safari) +export(ua_ps4) export(ua_splashr) export(ua_win10_chrome) export(ua_win10_firefox) diff --git a/NEWS.md b/NEWS.md index cd62508..905ceb7 100644 --- a/NEWS.md +++ b/NEWS.md @@ -2,6 +2,10 @@ * Switch Docker orchestration to the `stevedore` package * Fixed minor check on as.data.frame functions +* Cleaned up splashr object printing +* Added Android, Kindle, Apple TV & Chromecast user agents and updated + other user agents +* Updated Travis config to not use old docker pkg components 0.5.0 diff --git a/R/splashr.r b/R/splashr.r index b17c37a..d50d290 100644 --- a/R/splashr.r +++ b/R/splashr.r @@ -2,6 +2,10 @@ splash_url <- function(splash_obj) { sprintf("http://%s:%s", splash_obj$host, sp #' Configure parameters for connecting to a Splash server #' +#' +#' @md +#' @note There is a quick "helper" object named `splash_local` which is preconfigured +#' with `localhost` as the host name. #' @param host host or IP address #' @param port port the server is running on (default is 8050) #' @param user,pass leave `NULL` if basic auth is not configured. Otherwise, @@ -11,7 +15,29 @@ splash_url <- function(splash_obj) { sprintf("http://%s:%s", splash_obj$host, sp #' sp <- splash() #' } splash <- function(host, port=8050L, user=NULL, pass=NULL) { - list(host=host, port=port, user=user, pass=pass) + obj <- list(host=host, port=port, user=user, pass=pass) + class(obj) <- c("splashr", "list") + obj +} + +#' Print for splashr +#' +#' @md +#' @param x a splashr object +#' @param ... unused +#' @keywords internal +#' @return x +#' @export +print.splashr <- function(x, ...) { + + cat( + "\n", sep="" + ) + + invisible(x) + } #' @rdname splash diff --git a/R/user-agents.R b/R/user-agents.R index 16a8d34..25c2e63 100644 --- a/R/user-agents.R +++ b/R/user-agents.R @@ -46,3 +46,23 @@ ua_linux_firefox <- "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:51.0) Gecko/2010 #' @rdname splash_user_agent #' @export ua_ios_safari <- "Mozilla/5.0 (iPad; CPU OS 10_2 like Mac OS X) AppleWebKit/602.3.12 (KHTML, like Gecko) Version/10.0 Mobile/14C92 Safari/602.1" + +#' @rdname splash_user_agent +#' @export +ua_android_samsung <- "Mozilla/5.0 (Linux; Android 7.0; SM-G892A Build/NRD90M; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/60.0.3112.107 Mobile Safari/537.36" + +#' @rdname splash_user_agent +#' @export +ua_kindle <- "Mozilla/5.0 (X11; U; Linux armv7l like Android; en-us) AppleWebKit/531.2+ (KHTML, like Gecko) Version/5.0 Safari/533.2+ Kindle/3.0+" + +#' @rdname splash_user_agent +#' @export +ua_ps4 <- "Mozilla/5.0 (PlayStation 4 3.11) AppleWebKit/537.73 (KHTML, like Gecko)" + +#' @rdname splash_user_agent +#' @export +ua_apple_tv <- "AppleTV6,2/11.1" + +#' @rdname splash_user_agent +#' @export +ua_chromecast <- "Mozilla/5.0 (CrKey armv7l 1.5.16041) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.0 Safari/537.36" diff --git a/man/print.splashr.Rd b/man/print.splashr.Rd new file mode 100644 index 0000000..c8b5960 --- /dev/null +++ b/man/print.splashr.Rd @@ -0,0 +1,20 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/splashr.R +\name{print.splashr} +\alias{print.splashr} +\title{Print for splashr} +\usage{ +\method{print}{splashr}(x, ...) +} +\arguments{ +\item{x}{a splashr object} + +\item{...}{unused} +} +\value{ +x +} +\description{ +Print for splashr +} +\keyword{internal} diff --git a/man/splash.Rd b/man/splash.Rd index fd47fb4..4150e97 100644 --- a/man/splash.Rd +++ b/man/splash.Rd @@ -5,7 +5,7 @@ \alias{splash} \alias{splash_local} \title{Configure parameters for connecting to a Splash server} -\format{An object of class \code{list} of length 4.} +\format{An object of class \code{splashr} (inherits from \code{list}) of length 4.} \usage{ splash(host, port = 8050L, user = NULL, pass = NULL) @@ -16,12 +16,16 @@ splash_local \item{port}{port the server is running on (default is 8050)} -\item{user, pass}{leave `NULL` if basic auth is not configured. Otherwise, +\item{user, pass}{leave \code{NULL} if basic auth is not configured. Otherwise, fill in what you need for basic authentication.} } \description{ Configure parameters for connecting to a Splash server } +\note{ +There is a quick "helper" object named \code{splash_local} which is preconfigured +with \code{localhost} as the host name. +} \examples{ \dontrun{ sp <- splash() diff --git a/man/splash_user_agent.Rd b/man/splash_user_agent.Rd index f73bdce..d0fdc63 100644 --- a/man/splash_user_agent.Rd +++ b/man/splash_user_agent.Rd @@ -15,6 +15,11 @@ \alias{ua_linux_chrome} \alias{ua_linux_firefox} \alias{ua_ios_safari} +\alias{ua_android_samsung} +\alias{ua_kindle} +\alias{ua_ps4} +\alias{ua_apple_tv} +\alias{ua_chromecast} \title{Overwrite the User-Agent header for all further requests.} \format{An object of class \code{character} of length 1.} \usage{ @@ -43,6 +48,16 @@ ua_linux_chrome ua_linux_firefox ua_ios_safari + +ua_android_samsung + +ua_kindle + +ua_ps4 + +ua_apple_tv + +ua_chromecast } \arguments{ \item{splash_obj}{splashr object}