title: using R to web scrape data from javascripted download button
body: <p>I am trying to web scrape the csv generated by clicking the 'CSV' button on this <a href="https://www.bankofengland.co.uk/boeapps/database/fromshowcolumns.asp?Travel=NIxSTxTIxSUx&amp;FromSeries=1&amp;ToSeries=50&amp;DAT=RNG&amp;FD=1&amp;FM=Jan&amp;FY=2009&amp;TD=30&amp;TM=Mar&amp;TY=2020&amp;FNY=&amp;CSVF=TT&amp;html.x=91&amp;html.y=29&amp;C=IIN&amp;Filter=N#" rel="nofollow noreferrer">site</a> (located below the left side of the graph). The problem is that the CSV is generated from Javascript that parses the embedded table (below middle of graph). I am aware I could just scrape the embedded table . I do not want to do this.</p>
  
  <p>I want a solution that uses R to download a csv from the 'CSV' button. My attempt so far uses the r packages "rvest" and "V8". I'm just confused on what I do as I can't find good examples of the V8  package being used on javascript download buttons. Here's what I got so far.</p>
  
  <p>I'm confused on the line ct &lt;- v8() onwards... How do i apply the V8 package in the context of the javascript in the source code of the above URL?</p>
  
  <pre><code>library(rvest)
  library(V8)
  
  URL &lt;- https://www.bankofengland.co.uk/boeapps/database/fromshowcolumns.asp?Travel=NIxSTxTIxSUx&amp;FromSeries=1&amp;ToSeries=50&amp;DAT=RNG&amp;FD=1&amp;FM=Jan&amp;FY=2009&amp;TD=30&amp;TM=Mar&amp;TY=2020&amp;FNY=&amp;CSVF=TT&amp;html.x=91&amp;html.y=29&amp;C=IIN&amp;Filter=N#
  
  raw_html &lt;- GET(URL) %&gt;% 
       content() %&gt;% 
       rvest::html_nodes("script") %&gt;% 
       html_text() 
  
   ct &lt;- v8() 
  
     read_html(ct$eval(gsub('document.ready','',raw_html))) %&gt;% 
  
     html_text()
  </code></pre>
  
  <p>For Context, the javascript for the buttons are as below</p>
  
  <pre><code>&lt;script&gt;
  $(document).ready(function() {
      $.fn.dataTable.moment( 'DD MMM YY' );
  
      $('#stats-table').DataTable( {
      paging: false,
      "info":     false,
      "order": [ 0, 'desc' ],
      fixedHeader: {
      header: true
      },
       dom: 'Bfrtip',
          buttons: [
              'copy', 'csv', 'excel', 'print'
          ]
      } );
  
  } );
  &lt;/script&gt;
  </code></pre>