Rvest not recognizing css selector

前端 未结 2 670
醉话见心
醉话见心 2020-12-20 03:52

I\'m trying to scrape this website:

http://www.racingpost.com/greyhounds/result_home.sd#resultDay=2015-12-26&meetingId=18&isFullMeeting=true

through

2条回答
  •  轮回少年
    2020-12-20 04:35

    It's making an XHR request to generate the HTML. Try this (which should also make it easier to automate the data capture):

    library(httr)
    library(xml2)
    library(rvest)
    
    res <- GET("http://www.racingpost.com/greyhounds/result_by_meeting_full.sd",
               query=list(r_date="2015-12-26",
                          meeting_id=18))
    
    doc <- read_html(content(res, as="text"))
    
    html_nodes(doc, ".black")
    ## {xml_nodeset (56)}
    ##  [1] A9
    ##  [2] £61
    ##  [3] 470m
    ##  [4] -30
    ##  [5] H2
    ##  [6] £105
    ##  [7] 470m
    ##  [8] -30
    ##  [9] A7
    ## [10] £61
    ## [11] 470m
    ## [12] -30
    ## [13] A5
    ## [14] £66
    ## [15] 470m
    ## [16] -30
    ## [17] A8
    ## [18] £61
    ## [19] 470m
    ## [20] -20
    ## ...
    

提交回复
热议问题