title: How to get status code for urllib2 in python 2.7
body: <p>How do I get status code in python 2.7 for urllib2? I dont want to use requests. I need urllib2.</p>
  
  <pre><code>    request = urllib2.Request(url, headers=headers)
      contents = urllib2.urlopen(request).read()
      print request.getcode()
      contents = json.loads(contents) 
  
       &lt;type 'exceptions.AttributeError'&gt;, AttributeError('getcode',), &lt;traceback object at 0x7f6238792b48&gt;
  </code></pre>
  
  <p>Thanks</p>