title: R get html data from a javascript action
body: <p>I would like to scrape some data from a page where I need to click on a button (javascript) that give me access to a table. </p>
  
  <p>when your on <a href="http://www.si-vitifrance.com/docs/cvi/cvi13/cartes_inter/c_vin01_coop_com07/" rel="nofollow">http://www.si-vitifrance.com/docs/cvi/cvi13/cartes_inter/c_vin01_coop_com07/</a> you have access to a map and to the data table with a small 'table' button on the left.</p>
  
  <p>It opens a new window with the results and I would like to get this result in R. The url of this new page is <a href="http://www.si-vitifrance.com/docs/cvi/cvi13/cartes_inter/c_vin01_coop_com07/embfiles/table.html?th0" rel="nofollow">http://www.si-vitifrance.com/docs/cvi/cvi13/cartes_inter/c_vin01_coop_com07/embfiles/table.html?th0</a> but I can't have acces to this page if I don't come from the map page.</p>
  
  <p>So I would like to know if it's possible to simulate with R something that produce the same effect than a click on this button to have acces to this data.</p>
  
  <p>I have tried </p>
  
  <pre><code>path&lt;-"http://www.si-vitifrance.com/docs/cvi/cvi13/cartes_inter/c_vin01_coop_com07/embfiles/table.html?th0"
  webpage &lt;- getURL(path)
  webpage &lt;- readLines(tc &lt;- textConnection(webpage)); close(tc)
  </code></pre>
  
  <p>but the result obviously doesn't work </p>
  
  <pre><code> [1] "ï»¿&lt;!DOCTYPE HTML&gt;"                                                                                                  
   [2] "&lt;html&gt;"                                                                                                              
   [3] "&lt;meta http-equiv=\"Content-type\" content=\"text/html; charset=UTF-8\" /&gt;"                                           
   [4] "&lt;link rel=\"stylesheet\" href=\"style.css\" /&gt;"                                                                      
   [5] "&lt;link rel=\"stylesheet\" href=\"rectable.css\" /&gt;"                                                                   
   [6] "&lt;script language=\"JavaScript\" type=\"text/javascript\"&gt;"                                                           
   [7] "&lt;!--"                                                                                                                
   [8] "function sortTable(theColumn,datatype,orderby) {"                                                                    
   [9] "  document.getElementById(\"content\").innerHTML = \"Veuillez patientez ...\";"                                      
  [10] "  var themaId = window.location.search.substr(1,window.location.search.length);"                                     
  [11] "  var xslFile = \"styletable.xsl\";"                                                                                 
  [12] "  window.opener.mv_loadAttrTableFile(themaId,true);"                                                                 
  [13] "  try {"                                                                                                             
  [14] "\ttry {"                                                                                                             
  [15] "      var xslt = new ActiveXObject(\"Msxml2.XSLTemplate.4.0\");"                                                     
  [16] "      var xslDoc = new ActiveXObject(\"Msxml2.FreeThreadedDOMDocument.4.0\");"                                       
  [17] "    } catch(e) {"                                                                                                    
  [18] "      var xslt = new ActiveXObject(\"Msxml2.XSLTemplate\");"                                                         
  [19] "      var xslDoc = new ActiveXObject(\"Msxml2.FreeThreadedDOMDocument\");"                                           
  [20] "    }"                                                                                                               
  [21] "    xslDoc.async = false;"                                                                                           
  [22] "    xslDoc.resolveExternals = false;"                                                                                
  [23] "    xslDoc.load(xslFile);"                                                                                           
  [24] "    xslt.stylesheet = xslDoc;"                                                                                       
  [25] "    var xslProc = xslt.createProcessor();"                                                                           
  [26] "    xslProc.input = window.opener.mv_XMLFileArray[themaId].XMLFile;"                                                 
  [27] "    if (theColumn) {"                                                                                                
  [28] "      xslProc.addParameter(\"field\",\"f\" + (parseInt(theColumn) - 1));"                                            
  [29] "      xslProc.addParameter(\"datatype\",datatype);"                                                                  
  [30] "      xslProc.addParameter(\"orderby\",orderby);"                                                                    
  [31] "    }"                                                                                                               
  [32] "    xslProc.transform();"                                                                                            
  [33] "    content.innerHTML = xslProc.output;"                                                                             
  [34] "  } "                                                                                                                
  [35] ""                                                                                                                    
  [36] "  catch(e) {"                                                                                                        
  [37] "    var xsltProcessor = new XSLTProcessor(); "                                                                       
  [38] "    var xslStylesheet = window.opener.mv_loadXMLDoc(window.opener.mv_Doc.BaseURL + \"embfiles/\" + xslFile,\"xml\");"
  [39] "    try {"                                                                                                           
  [40] "      xsltProcessor.importStylesheet(xslStylesheet);"                                                                
  [41] "    }"                                                                                                               
  [42] "    catch(err) {"                                                                                                    
  [43] "      var xslStylesheet = document.implementation.createDocument(\"\", \"\", null);"                                 
  [44] "      xslStylesheet.async = false;"                                                                                  
  [45] "      xslStylesheet.load(xslFile);"                                                                                  
  [46] "      xsltProcessor.importStylesheet(xslStylesheet);"                                                                
  [47] "    }"                                                                                                               
  [48] "    if (theColumn) {"                                                                                                
  [49] "      xsltProcessor.setParameter(null,\"field\",\"f\" + (parseInt(theColumn) - 1));"                                 
  [50] "      xsltProcessor.setParameter(null,\"datatype\",datatype);"                                                       
  [51] "      xsltProcessor.setParameter(null,\"orderby\",orderby);"                                                         
  [52] "    }"                                                                                                               
  [53] "    var resultFragment = xsltProcessor.transformToFragment(window.opener.mv_XMLFileArray[themaId].XMLFile,document);"
  [54] "    document.getElementById(\"content\").innerHTML = \"\";"                                                          
  [55] "    document.getElementById(\"content\").appendChild(resultFragment);"                                               
  [56] "  }"                                                                                                                 
  [57] "}"                                                                                                                   
  [58] "//--&gt;"                                                                                                               
  [59] "&lt;/script&gt;"                                                                                                           
  [60] "&lt;title&gt;Table attributaire&lt;/title&gt;"                                                                                   
  [61] "&lt;/head&gt;"                                                                                                             
  [62] "&lt;body onload=\"sortTable();\"&gt;"                                                                                      
  [63] "&lt;div id=\"content\"&gt;Veuillez patientez ...&lt;/div&gt;"                                                                    
  [64] "&lt;/body&gt;"                                                                                                             
  [65] "&lt;/html&gt;"                                                                                                             
  [66] "" 
  </code></pre>
  
  <p>any ideas ?</p>
  
  <p>thank you</p>