title: Data Scraping in R
body: <p>I'd like to use the statistics from the Premier League's website for a class project. 
  This is the website:
  <a href="https://www.premierleague.com/stats/top/players/goals" rel="nofollow noreferrer">https://www.premierleague.com/stats/top/players/goals</a></p>
  
  <p>There are filters that allow us to filter by season and other factors, and a button at the bottom of the page that allows us to view the next 20 entries in the table.</p>
  
  <p>My code is as follows: </p>
  
  <pre><code>library(tidyverse)
  library(rvest)
  url &lt;- "https://www.premierleague.com/stats/top/players/goals?se=79"
  url %&gt;%
    read_html() %&gt;% 
    html_nodes("table") %&gt;% 
    .[[1]] %&gt;% 
     html_table()
  </code></pre>
  
  <p>which outputs:</p>
  
  <pre><code>   Rank                  Player            Club         Nationality Stat
  1     1            Alan Shearer               -             England  260
  2     2            Wayne Rooney         Everton             England  208
  3     3             Andrew Cole               -             England  187    
  4     4           Frank Lampard               -             England  177
  5     5           Thierry Henry               -              France  175
  6     6           Robbie Fowler               -             England  163
  7     7           Jermain Defoe AFC Bournemouth             England  162
  8     8            Michael Owen               -             England  150
  9     9           Les Ferdinand               -             England  149
  10   10        Teddy Sheringham               -             England  146
  11   11        Robin van Persie               -         Netherlands  144
  12   12           Sergio Agüero Manchester City           Argentina  143
  13   13 Jimmy Floyd Hasselbaink               -         Netherlands  127
  14   14            Robbie Keane               -             Ireland  126
  15   15          Nicolas Anelka               -              France  125
  16   16            Dwight Yorke               - Trinidad And Tobago  123
  17   17          Steven Gerrard               -             England  120
  18   18              Ian Wright               -             England  113
  19   19             Dion Dublin               -             England  111
  20   20            Emile Heskey               -             England  110
  </code></pre>
  
  <p>However, when changing filters on the site (for instance, in my use case, restricting the table to the current season), and using the arrows to access the next 20 entries in the table, the URL does not change. </p>
  
  <p>I have found the relevant areas of the source code. They are: </p>
  
  <pre><code>&lt;div data-script="pl_stats" data-widget="stats-table" data-current-size="20" 
  data-stat="" data-type="player" data-page-size="20" data-page="0" data- 
  comps="1" data-num-entries="2162"&gt;
  
  &lt;div class="dropDown noLabel topStatsFilterDropdown" data-listener="true"&gt;
      &lt;div data-metric="mins_played" class="current currentStatContainer" 
  aria-expanded="false"&gt;Minutes played&lt;/div&gt;
      &lt;ul class="dropdownList" role="listbox"&gt;
  </code></pre>
  
  <p>I would like to be able to modify the data-metric and data-page fields. </p>