title: Requests -- how to tell if you're getting a 404
body: <p>I'm using the Requests library and accessing a website to gather data from it with the following code: </p>
  
  <pre><code>r = requests.get(url)
  </code></pre>
  
  <p>I want to add error testing for when an improper URL is entered and a 404 error is returned. If I intentionally enter an invalid URL, when I do this:</p>
  
  <pre><code>print r
  </code></pre>
  
  <p>I get this:</p>
  
  <pre><code>&lt;Response [404]&gt;
  </code></pre>
  
  <p>EDIT:</p>
  
  <p>I want to know how to test for that. The object type is still the same. When I do <code>r.content</code> or <code>r.text</code>, I simply get the HTML of a custom 404 page. </p>