title: Multiple pages in Rvest
body: <p>I am working on web scraping using Rvest in R.
  I tried to fetch data from search pages which has 12 pages. And I wrote a code to iterate page to collect data from each page. But my code collects only 1st page repeatedly. Here is the sample for my code.</p>
  <pre><code># New method for Pagination
  url_base &lt;- &quot;https://www.nhs.uk/service-search/Hospital/LocationSearch/7/ConsultantResults?SortBy=1&amp;Distance=400&amp;ResultsPerPage=10&amp;Name=e.g.%20Singh%20or%20John%20Smith&amp;Specialty=230&amp;Location.Id=0&amp;Location.Name=e.g.%20postcode%20or%20town&amp;Location.Longitude=0&amp;Location.Latitude=0&amp;CurrentPage=1&amp;OnlyViewConsultantsWithOutcomeData=False&quot;
  map_df(1:12, function(i) {
    cat(&quot;.&quot;)
    pg &lt;- read_html(sprintf(url_base,i))
    data.frame(consultant_name = html_text(html_nodes(pg,&quot;.consultants-list h2 a&quot;)))
    
  }) -&gt; names
  
  dplyr::glimpse(names)
  </code></pre>
  <p>Edited Version of code:</p>
  <pre><code># New method for Pagination
  url_base  &lt;-  &quot;https://www.nhs.uk/service-search/Hospital/LocationSearch/7/ConsultantResults?ResultsPerPage=100&amp;defaultConsultantName=e.g.+Singh+or+John+Smith&amp;DefaultLocationText=e.g.+postcode+or+town&amp;DefaultSearchDistance=25&amp;Name=e.g.+Singh+or+John+Smith&amp;Specialty=230&amp;Location.Name=e.g.+postcode+or+town&amp;Location.Id=0&amp;CurrentPage=%d&quot;
  map_df(1:12, function(i) {
    cat(&quot;.&quot;)
    pg &lt;- read_html(sprintf(url_base,i))
    data.frame(consultant_name = html_text(html_nodes(pg,&quot;.consultants-list h2 a&quot;)),
               gmc_no = gsub(&quot;GMC membership number: &quot;,&quot;&quot;,html_text(html_nodes(pg,&quot;.consultants-list .name-number p&quot;))),
               Speciality = html_text(html_nodes(pg,&quot;.consultants-list .specialties ul li&quot;)),
               location = html_text(html_nodes(pg,&quot;.consultants-list .consultant-services ul li&quot;)),stringsAsFactors=FALSE)
    
  }) -&gt; names
  
  dplyr::glimpse(names)
  </code></pre>
  <p>The above code accepts 8 loops fetching rows of 800 i.e 100 per page but then it throes an error.</p>
  <blockquote>
  <blockquote>
  <p>.........Error in data.frame(consultant_name = html_text(html_nodes(pg, &quot;.consultants-list h2 a&quot;)),  :    arguments
  imply differing number of rows: 100, 101 Called from:
  data.frame(consultant_name = html_text(html_nodes(pg,
  &quot;.consultants-list h2 a&quot;)),
  gmc_no = gsub(&quot;GMC membership number: &quot;, &quot;&quot;,
  html_text(html_nodes(pg, &quot;.consultants-list .name-number p&quot;))),
  Speciality = html_text(html_nodes(pg, &quot;.consultants-list .specialties ul li&quot;)),
  location = html_text(html_nodes(pg, &quot;.consultants-list .consultant-services ul li&quot;)),
  stringsAsFactors = FALSE) Browse[1]&gt;</p>
  </blockquote>
  </blockquote>
  <p>I tried to change the loop numbers but no luck.</p>
  <p>Please help me to solve this!!!</p>