title: R Rvest for() and Error server error: (503) Service Unavailable
body: <p>I'm  new to webscraping, but I am excited using <code>rvest</code> in R. 
  I tried to use it to scrape particular data of companies.
  I have created a for loop (171 urls), and when I am running it stops on 6th or 7th url with an error </p>
  
  <pre><code>Error in parse.response(r, parser, encoding = encoding) : 
    server error: (503) Service Unavailable
  </code></pre>
  
  <p>When I start my loop from 7th url it goes for two or three more and stops again with the same error.
  My loop</p>
  
  <pre><code>library(rvest)    
  thing&lt;-c("http://www.informazione-aziende.it/Azienda_ LA-VIS-S-C-A",                                                                                  
      "http://www.informazione-aziende.it/Azienda_ L-ANGOLO-DEL-DOLCE-DI-OBEROSLER-MARCO",                                                         
      "http://www.informazione-aziende.it/Azienda_ MARCHI-LAURA",                                                                                 
      "http://www.informazione-aziende.it/Azienda_ LAVIS-PIZZA-DI-GASPARETTO-MATTEO",                                                              
      "http://www.informazione-aziende.it/Azienda_ LE-DELIZIE-MOCHENE-DI-OSLER-NICOLA",                                                            
      "http://www.informazione-aziende.it/Azienda_ LE-DELIZIE-S-N-C-DI-GAMBONI-PIETRO-E-PISONI-MAURO-C-IN-SIGLA-LE-DELIZIE-S-N-C",                 
      "http://www.informazione-aziende.it/Azienda_ LE-FONTI-DISTILLATI-DI-COVI-MARCELLO",                                                          
      "http://www.informazione-aziende.it/Azienda_ LE-MIGOLE-DI-MATTEOTTI-LUCA",                                                                   
      "http://www.informazione-aziende.it/Azienda_ LECHTHALER-DI-TOGN-LUIGI-E-C-S-N-C",                                                            
      "http://www.informazione-aziende.it/Azienda_ LETRARI-AZ-AGRICOLA")
  
      thing&lt;-gsub(" ", "", thing)
  
      d &lt;- matrix(nrow=10, ncol=4)
      colnames(d)&lt;-c("RAGIONE SOCIALE",'ATTIVITA', 'INDIRIZZO', 'CAP')
  
      for(i in 1:10) {
              a&lt;-thing[i]
  
              urls&lt;-html(a)
  
              d[i,2] &lt;- try({ urls %&gt;% html_node(".span") %&gt;% html_text() }, silent=TRUE)
      }
  </code></pre>
  
  <p>May be there is a way to avoid this error, thank you in advance, any help would be appreciated. </p>
  
  <p>UPD
  With next code, I am trying to restart the loop of fetching data, from the last successful one with <code>repeat()</code>, but it is looping infinitely, hope for some suggestions.</p>
  
  <pre><code>    for(i in 1:10) {
  
    a&lt;-thing[i]
  
    try({d[i,2]&lt;- try({html(a) }, silent=TRUE)  %&gt;%
           html_node(".span") %&gt;%
           html_text() }, silent=TRUE)
  
    repeat {try({d[i,2]&lt;- try({html(a) }, silent=TRUE)  %&gt;%
                   html_node(".span") %&gt;%
                   html_text() }, silent=TRUE)}
    if (!is.na(d[i,2])) break
  }
  </code></pre>
  
  <p>Or with <code>while()</code></p>
  
  <pre><code>for(i in 1:10) {
  
    a&lt;-thing[i]
  
  while (is.na(d[i,2])) {
    try({d[i,2]&lt;-try({html(a) %&gt;%html_node(".span")},silent=TRUE) %&gt;% html_text() },silent=TRUE)
  }
  }
  </code></pre>
  
  <p><code>While()</code> works but not so good and too slow (( </p>