Scraping table from web page with rvest

R Markdown for using rvest

This is an the code to use rvest package to scrape table from the website
https://www.hnx.vn/vi-vn/trai-phieu/ket-qua-gd-trong-ngay.html?site=in

The table is in multiple pages. I got an empty table and no error. Could someone please help with the issue?

require(dplyr)
require(rvest)


options(stringsAsFactors = FALSE)

url_base <- "https://www.hnx.vn/vi-vn/trai-phieu/ket-qua-gd-trong-ngay.html"
tbl.clactions <- data.frame(
  "SST" = character(0),
  "Ngày giao kết giao dịch" = character(0),
  "Kỳ hạn còn lại" = character(0),
  "Mã TP" = character(0),
  "Tiền tệ" = character(0),
  "Giá yết"  = character(0),
  "Lợi suất (%/năm)"  = character(0),
  "KLGD"  = character(0),
  "GTGD (đồng)"  = character(0),
  "Ngày thanh toán"  = character(0))

for (i in 1:ceiling(65/10)) {  # total filings: 38, listed 10 per page
  url <- paste0(url_base, i)
  tbl.page <- url %>%
    read_html() %>%
    html_nodes(xpath='//*[@id="_tableDatas"]') %>%
    html_table()
 names(tbl.page)[[1]] <- names(tbl.clactions)
 tbl.clactions <- bind_rows(tbl.clactions, tbl.page[[1]]) 
 }

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.