Created
July 23, 2024 22:34
-
-
Save bbolker/9e7fdd535e24bb75ee7bf08e29443987 to your computer and use it in GitHub Desktop.
code to scrape the list of bright stars from Wikipedia and count by hemisphere
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## https://ivelasq.rbind.io/blog/politely-scraping/index.html | |
## To clean data | |
library(tidyverse) | |
library(lubridate) | |
library(janitor) | |
# To scrape data | |
library(rvest) | |
library(httr) | |
library(polite) | |
url <- "https://en.wikipedia.org/wiki/List_of_brightest_stars" | |
url_bow <- polite::bow(url) | |
ind_html <- | |
polite::scrape(url_bow) %>% # scrape web page | |
rvest::html_nodes("table.wikitable:nth-child(22)") %>% # pull out specific table | |
rvest::html_table(fill = TRUE) | |
tab <- ind_html[[1]] | |
tab |> count(`Celestial Hemisphere`) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment