title: web scraping in r (with loop)
body: <p>I need to scrapes data from <a href="https://bra.areacodebase.com/number_type/M?page=0" rel="nofollow noreferrer">this link</a>  and save table in csv. What I have now: 
  I can scrap using rvest the first page, second page and save these tables using this code:</p>
  
  <pre><code>library(rvest)
  webpage &lt;- read_html("https://bra.areacodebase.com/number_type/M?page=0")
  data &lt;- webpage %&gt;%
    html_nodes("table") %&gt;%
    .[[1]] %&gt;% 
    html_table()
   url&lt;- "https://bra.areacodebase.com/number_type/M?page=0"
  webpage2&lt;- html_session(url) %&gt;% follow_link(css = ".pager-next a")
  data2 &lt;- webpage %&gt;%
   html_nodes("table") %&gt;%
   .[[1]] %&gt;%
    html_table()
  data_all &lt;- rbind(data, data2)
  write.table(data_all, "df_data.csv", sep = ";", na = "", quote = FALSE, row.names = FALSE)
  
  #result&lt;- lapply(webpage, %&gt;% follow_link(css = ".pager-next a"))
  #data_all &lt;- rbind(data:data2)
  </code></pre>
  
  <p>However, I can't figure out how to run loop.</p>