0

I would like to access to a web page with R and rcurl package. Here is my code :

library(RCurl) library(XML)

URL <- "http://www.lfp.fr/ligue1/calendrier_resultat#sai=82&jour=1"
siteHTML <- getURL(url=URL)
xmltext <- htmlParse(siteHTML, asText=TRUE, encoding = 'UTF-8')
Date_Match <- sapply(xpathSApply(xmltext, '//*[@id="tableaux_rencontres"]//h4'), xmlValue) 
Date_Match

The result is not good ... like if the jour=1 parameter doesn't not exist. If I try to access to this page with Firefox, it's Ok.

I have also try this code without success :

x <- getForm("http://www.lfp.fr/ligue1/calendrier_resultat",
       jour="2",
       sai="82")
xmltext <- htmlParse(x, asText=TRUE, encoding = 'UTF-8')
Date_Match <- sapply(xpathSApply(xmltext, '//*[@id="tableaux_rencontres"]//h4'), xmlValue) 
Date_Match

Do you know why ? What is the solution ? Can you help me ? I'm beginner in R programming, so don't hesitate to give large explanation.

perror
  • 7,071
  • 16
  • 58
  • 85

1 Answers1

1

Use ? instead of # in the url:

library(RCurl)
library(XML)
URL <- "http://www.lfp.fr/ligue1/calendrier_resultat?sai=82&jour=1"
siteHTML <- getURL(url=URL)
xmltext <- htmlParse(siteHTML, asText=TRUE, encoding = 'UTF-8')
Date_Match <- sapply(xpathSApply(xmltext, '//*[@id="tableaux_rencontres"]//h4'), xmlValue)
Date_Match
# [1] "Vendredi 14 février 2014" "Samedi 15 février 2014"   "Dimanche 16 février 2014"
lukeA
  • 53,097
  • 5
  • 97
  • 100