r - Web scrape with rvest from a table that is not defined -


i trying table website : http://www.oddsportal.com/american-football/usa/nfl-2012-2013/results/

i want table in middle of page.

i tried different ways in vain.

library("rvest") library(dplyr)  url1 <- "http://www.oddsportal.com/american-football/usa/nfl-2012-2013/results/" table <- url1 %>%   read_html() %>%   html_nodes(xpath='//*[@id="tournamenttable"]') %>%    html_table(fill = t) 

this not work because believe table not defined table.

i tried grab rows separately using:

 df <- mps1 %>%       html_nodes(css = "tr.odd.deactivate,tr.center.nob-border") 

but obtains nothing.

any idea how can it?

thanks

based on previous questions people trying scrape site, table dynamically generated. far know, way deal pages use rselenium - automates browser.

after lot of trial , error, following code seems work (using chrome on windows 10)...

library(rselenium) library(rvest) library(dplyr)  url <- "http://www.oddsportal.com/american-football/usa/nfl-2012-2013/results/" rd <- rsdriver(port=4444l,browser="chrome") remdr <- rd$client  remdr$navigate(url)  page <- remdr$getpagesource() remdr$close() #you can leave open if doing several of these: close @ end  table <- page[[1]] %>%   read_html() %>%   html_nodes(xpath='//table[@id="tournamenttable"]') %>% #specify table there div same id   html_table(fill = t)  table <- table[[1]]  head(table)    american football» usa»nfl 2012/2013   american football» usa»nfl 2012/2013   american football» usa»nfl 2012/2013 american football» usa»nfl 2012/2013 american football» usa»nfl 2012/2013 american football» usa»nfl 2012/2013 1              03 feb 2013 - play offs                03 feb 2013 - play offs                03 feb 2013 - play offs              03 feb 2013 - play offs                                 1.00                                 2.00 2                                                                                                                                                                                           na                                   na 3                                23:30 san francisco 49ers - baltimore ravens san francisco 49ers - baltimore ravens                                31:34                                 1.49                                 2.71 4              28 jan 2013 - stars                28 jan 2013 - stars                28 jan 2013 - stars              28 jan 2013 - stars                                 1.00                                 2.00 5                                                                                                                                                                                           na                                   na 6                                00:00                              nfc - afc                              nfc - afc                                62:35                                 2.03                                 1.83   american football» usa»nfl 2012/2013 1                                  b's 2                                      3                                    9 4                                  b's 5                                      6                                    9 

the odds coming out decimal numbers, unfortunately, can work that.


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -