README.md

curlR

R-CMD-check codecov License CRAN

Installation

1. Windows

环境配置详见:https://gitlab.com/r-pkgs/curlr.bin

remotes::install_github("rpkgs/curlR", INSTALL_opts="--no-staged-install")

Example

library(curlR)

port = 4444
kill_selenium(port)
p <- init_selenium(port)

p %>% go("https://cn.bing.com/")
getElementByName(p, "q") %>% ele_fillText("curlR", key = "enter")
# getElementByName(p, "go") %>% ele_click()

# GET ALL results
xs = ele_find_all(p, "//ol/li", "xpath")

# GET the first result
x = ele_find_first(p, "//ol/li", "xpath")
a = ele_child(x, "//a") # get link
a %>% clickElement()
# if page changed, previous node will be destroyed

selenium

Linux

sudo apt install firefox-geckodriver chromium-chromedriver 
sudo apt install chromium-browser

Reference

  1. https://extendsclass.com/xpath-to-css.html


rpkgs/curlR documentation built on Jan. 30, 2023, 7:26 p.m.