4

I have some experience in R but completely new to JavaScript. I am recently trying to scrape a table from this website (http://op1.win007.com/Oddslist/1599893.htm). It seems to me that the webpage is written in JavaScript and therefore the simple way of using rvest to scrape does not work. Below is the way to scrape the table I need if it is in plain HTML:

library(rvest)
link <- "http://op1.win007.com/Oddslist/1599893.htm"
MyTable <- read_html(link) %>% html_nodes("oddsList_tab") %>% html_table(fill = TRUE)

The code above gives me an empty list which is not I want. Upon looking at other posts and V8 tutorial, I come up with the following:

library(rvest)
library(V8)
link <- "http://op1.win007.com/Oddslist/1599893.htm"

MyText <- read_html(link) %>% html_nodes('script') %>% html_text()

ct <- v8()
html_nodes(MyText, "oddsList_tab") %>% html_text() %>% ct$eval()

I have no idea which part is wrong since I am new to JavaScript. In addition, I would also like to get the pop-up tables which hovering the mouse over the numbers inside the tables. Apparently I have no idea how to do this given I had difficulty scraping the table on surface.

I read from other posts that it may require filling in some variables but I have no idea whether I have to do this and how I can do this.

It would be great if someone can show me how to do it and possibly explain to me how it works.

Thank you very much.

Bosco Lam
  • 43
  • 2

0 Answers0