title: Check response using urllib2
body: <p>I am trying access a page by incrementing the page counter using opencorporates api. But the problem is there are times when useless data is there. For example in the below url for jurisdiction_code = ae_az I get webpage showing just this:</p>
  
  <pre><code>{"api_version":"0.2","results":{"companies":[],"page":1,"per_page":26,"total_pages":0,"total_count":0}}
  </code></pre>
  
  <p>which is technically empty. How to check for such data and skip over this to move on to next jurisdiction?</p>
  
  <p>This is my code</p>
  
  <pre><code>import urllib2
  import json,os
  
  f = open('codes','r')
  for line in f.readlines():
     id = line.strip('\n')
     url = 'http://api.opencorporates.com/v0.2/companies/search?q=&amp;jurisdiction_code={0}&amp;per_page=26&amp;current_status=Active&amp;page={1}?api_token=ab123cd45' 
     i = 0
     directory = id
     os.makedirs(directory)
     while True:
        i += 1
        req = urllib2.Request(url.format(id, i))
        print url.format(id,i)
        try:
          response = urllib2.urlopen(url.format(id, i))
        except urllib2.HTTPError, e:
          break
        content = response.read()
        fo = str(i) + '.json'    
        OUTFILE = os.path.join(directory, fo)
        with open(OUTFILE, 'w') as f:
          f.write(content)
  </code></pre>