Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

To perform web scraping of information about the Joseon Dynasty from Wikipedia using R Studio, you can follow these steps:

  1. First, you need to install the "rvest" package in R Studio. You can do this by typing the following command in the console:

.packages("rvest")

  1. After installing the package, load it into your R session with this command:

(rvest)

  1. Next, you can use the 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)

  1. Once you have the HTML content, you can use the 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()

  1. To retrieve a specific section of the page, you can use the 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()

  1. You can also use the 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()

  1. Finally, you can use the retrieved data for further analysis and visualization in R Studio.