Johanna
Johanna

Reputation: 3

HTML Scraping using R for simple table

I am trying to scrape the table on this website : https://www.kimiafarma.co.id/index.php?option=com_content&view=article&id=193&Itemid=353&lang=id

I've tried using :

enter image description here

I would like to scrape the data from that table and put it in an excel file, but I'm quite new to R programming and web scraping. I would appreciate if someone could explain what I need to do step by step.

Upvotes: 0

Views: 45

Answers (1)

Ronak Shah
Ronak Shah

Reputation: 388982

You can use :

library(rvest)
url <- 'https://www.kimiafarma.co.id/index.php?option=com_content&view=article&id=193&Itemid=353&lang=id'

data <- url %>%
          read_html() %>%
          html_nodes('table') %>%
          .[[1]] %>%
          html_table()

To write data as csv, you can use write.csv

write.csv(data, 'data.csv', row.names = FALSE)

Upvotes: 1

Related Questions