R rvest package for web scraping. Use for scraping data from web pages.
Scanned 6/5/2026
Install via CLI
openskills install LeoLin990405/r-analytics-skill---
name: rvest
description: R rvest package for web scraping. Use for scraping data from web pages.
---
# rvest
Easily harvest web pages.
## Basic Scraping
```r
library(rvest)
# Read HTML
page <- read_html("https://example.com")
# From file
page <- read_html("page.html")
```
## Selecting Elements
```r
# CSS selectors
page %>% html_elements("p")
page %>% html_elements(".class")
page %>% html_elements("#id")
page %>% html_elements("div.class")
page %>% html_elements("table tr")
# XPath
page %>% html_elements(xpath = "//div[@class='content']")
```
## Extracting Data
```r
# Text content
page %>%
html_elements("p") %>%
html_text()
# Clean text (removes whitespace)
page %>%
html_elements("p") %>%
html_text2()
# Attributes
page %>%
html_elements("a") %>%
html_attr("href")
# All attributes
page %>%
html_elements("a") %>%
html_attrs()
```
## Tables
```r
# Extract tables
tables <- page %>%
html_elements("table") %>%
html_table()
# First table
df <- tables[[1]]
# With options
page %>%
html_element("table") %>%
html_table(header = TRUE, fill = TRUE)
```
## Forms
```r
# Find form
form <- page %>%
html_form()[[1]]
# Fill form
form <- form %>%
html_form_set(
username = "user",
password = "pass"
)
# Submit form
session <- session("https://example.com")
session <- session_submit(session, form)
```
## Sessions
```r
# Start session
session <- session("https://example.com")
# Navigate
session <- session_follow_link(session, "Next")
session <- session_jump_to(session, "https://example.com/page2")
# Go back
session <- session_back(session)
# Get current page
session %>% read_html()
```
## Handling JavaScript
```r
# rvest doesn't execute JavaScript
# For JS-rendered pages, use RSelenium or chromote
# Or find the API endpoint
# Check Network tab in browser DevTools
```
## Example: Scrape Table
```r
library(rvest)
library(dplyr)
url <- "https://en.wikipedia.org/wiki/List_of_countries_by_population"
page <- read_html(url)
df <- page %>%
html_element("table.wikitable") %>%
html_table() %>%
clean_names()
```
No comments yet. Be the first to comment!
This skill helps you track, analyze, and report on keyword ranking positions over time. It monitors both traditional SERP rankings and AI/GEO visibility to provide comprehensive search performance insights.
Find and analyze YouTube competitor channels using YouTube Data API v3. Discover competitors through keyword search, category matching, content similarity, and related channel discovery. Compare metrics, content strategies, and market positioning. Use when users want to (1) Find competitors for their YouTube channel, (2) Analyze competitor performance metrics, (3) Compare their channel against competitors, (4) Identify content gaps and opportunities, (5) Benchmark against similar creators, (6...
Get current weather and forecasts (no API key required).
Focused Signals scout for PostHog projects using revenue analytics. Watches the derived revenue product for upstream failures (Stripe sync stalls, capture regressions), config drift (missing subscription property, currency mix surprises, broken Stripe↔person joins, deferred-revenue gaps), and goal-miss escalations. Emits findings only when they clear the confidence bar; otherwise writes durable memory and closes out empty. Self-contained peer in the signals-scout-* fleet — no dependencies on ...
Focused Signals scout for finding observability gaps in PostHog itself — significant event volumes the team isn't tracking, custom events with no insight or dashboard coverage, insights pointing at events that have stopped firing, dashboards missing related context, critical events with no alerts. Watches the event-stream-vs-saved- inventory delta as the team's product evolves and emits findings recommending new insights, dashboard additions, or alerts when gaps clear the confidence bar. Self...