title: Rvest How to avoid the Error in open.connection(x, "rb") : HTTP error 404 R
body: <p>I'd like to take some informations from a list of website.
  I have a list of urls, but there are some that doesn't work/exesist.</p>
  
  <p>The Error is:  </p>
  
  <blockquote>
    <p>Error in open.connection(x, "rb") : HTTP error 404 R</p>
  </blockquote>
  
  <pre><code>library(Rvest)
  url_web&lt;-(c("https://it.wikipedia.org/wiki/Roma",
          "https://it.wikipedia.org/wiki/Milano",
          "https://it.wikipedia.org/wiki/Napoli",
          "https://it.wikipedia.org/wiki/Torinoooo", # for example this is an error
          "https://it.wikipedia.org/wiki/Palermo",
          "https://it.wikipedia.org/wiki/Venezia"))
  </code></pre>
  
  <p>I write this code for my target. </p>
  
  <p>I tried to use <code>try</code>, but doesn't work.</p>
  
  <p>I tried to use an <code>ifelse(url.exists(url_web)==TRUE,Cont&lt;-read_html(url_web), NA )</code> into the <code>for</code>, but doesn't work.</p>
  
  <pre><code>for (i in 1:length(url_web)){
        Cont&lt;-read_html(i)
        Dist_1&lt;-html_nodes(Cont, ".firstHeading") %&gt;% 
        html_text()
        print(Dist_1)
      }
  </code></pre>
  
  <p>The question is: How I can jump the url where I can't link or where is writes wrong?</p>
  
  <p>Thank you in advance. </p>
  
  <p>Francesco</p>