1 | initial version |
To perform web scraping of information about the Joseon Dynasty from Wikipedia using R Studio, you can follow these steps:
.packages("rvest")
(rvest)
read_html()
function to retrieve the HTML content of the Wikipedia page about the Joseon Dynasty:<- "https://en.wikipedia.org/wiki/Joseon"
<- read_html(url)
html_nodes()
function to select specific elements from the page. For example, you can use the following code to retrieve all the headings on the page:<- page %>% html_nodes("h2, h3") %>% html_text()
html_node()
function with a CSS selector to select the relevant element. For example, to retrieve the "Culture" section, you can use this code:_section <- page %>% html_node("#Culture") %>% html_text()
html_table()
function to extract tables from the page. For example, to retrieve the table of Joseon Dynasty kings, you can use this code:_table <- page %>% html_nodes("table.wikitable")[[1]] %>% html_table()