Packages

dalam melakukan web scraping maka dibutuhkan packages-packages terlebih dahulu, adapun packages tersebut yaitu: rvest, dplyr

library(rvest)
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union

Web target

dalam melakukan web scraping, maka terlebih dahulu menentukan web target, web target tersebut kemudian melakukan inspect dalam source code

url_link="https://id.investing.com/crypto/newyorkcoin/nyc-usd-historical-data"
url_page= read_html(url_link)

hasil Scraping

untuk menampilkan scraping, dibutuhkan source code dari sebuah web yang akan di lakukan scraping.

data_table= url_page %>% html_nodes("table#curr_table") %>%
  html_table() %>% .[[1]]
data_table
## # A tibble: 32 x 7
##    Tanggal    Terakhir   Pembukaan  Tertinggi  Terendah   Vol.    `Perubahan%`
##    <chr>      <chr>      <chr>      <chr>      <chr>      <chr>   <chr>       
##  1 09/06/2021 0,00003528 0,00003528 0,00003528 0,00003528 -       0,00%       
##  2 08/06/2021 0,00003528 0,00004024 0,00004045 0,00003528 327,35K -12,33%     
##  3 07/06/2021 0,00004024 0,00004050 0,00004050 0,00004024 123,44K -0,64%      
##  4 06/06/2021 0,00004050 0,00004057 0,00004057 0,00004050 1,49M   -0,17%      
##  5 05/06/2021 0,00004057 0,00004108 0,00004152 0,00004057 11,37M  -1,24%      
##  6 04/06/2021 0,00004108 0,00004202 0,00004202 0,00004108 316,78K -2,24%      
##  7 03/06/2021 0,00004202 0,00004436 0,00005388 0,00004202 1,14M   -5,28%      
##  8 02/06/2021 0,00004436 0,00004107 0,00005000 0,00004107 7,83M   8,01%       
##  9 01/06/2021 0,00004107 0,00003377 0,00004107 0,00003377 3,93M   21,62%      
## 10 31/05/2021 0,00003377 0,00003777 0,00003777 0,00003377 2,43M   -10,59%     
## # ... with 22 more rows