title: 503 error when trying to access Google Patents using python
body: <p>Earlier today I was able to pull data from Google Patents using the code below</p>
  
  <pre><code>import urllib2
  
  url = 'http://www.google.com/search?tbo=p&amp;q=ininventor:"John-Mudd"&amp;hl=en&amp;tbm=pts&amp;source=lnt&amp;tbs=ptso:us'
  req = urllib2.Request(url, headers={'User-Agent' : "foobar"})
  
  response = urllib2.urlopen(req)
  </code></pre>
  
  <p>Now when I go to run it I get the following 503 error. I had only looped through this code maybe 30 times on it (i'm trying to get all the patents owned by a list of 30 people).</p>
  
  <pre><code>HTTPError                                 Traceback (most recent call last)
  &lt;ipython-input-4-01f83e2c218f&gt; in &lt;module&gt;()
  ----&gt; 1 response = urllib2.urlopen(req)
  
  C:\Python27\lib\urllib2.pyc in urlopen(url, data, timeout)
      124     if _opener is None:
      125         _opener = build_opener()
  --&gt; 126     return _opener.open(url, data, timeout)
      127 
      128 def install_opener(opener):
  
  C:\Python27\lib\urllib2.pyc in open(self, fullurl, data, timeout)
      404         for processor in self.process_response.get(protocol, []):
      405             meth = getattr(processor, meth_name)
  --&gt; 406             response = meth(req, response)
      407 
      408         return response
  
  C:\Python27\lib\urllib2.pyc in http_response(self, request, response)
      517         if not (200 &lt;= code &lt; 300):
      518             response = self.parent.error(
  --&gt; 519                 'http', request, response, code, msg, hdrs)
      520 
      521         return response
  
  C:\Python27\lib\urllib2.pyc in error(self, proto, *args)
      436             http_err = 0
      437         args = (dict, proto, meth_name) + args
  --&gt; 438         result = self._call_chain(*args)
      439         if result:
      440             return result
  
  C:\Python27\lib\urllib2.pyc in _call_chain(self, chain, kind, meth_name, *args)
      376             func = getattr(handler, meth_name)
      377 
  --&gt; 378             result = func(*args)
      379             if result is not None:
      380                 return result
  
  C:\Python27\lib\urllib2.pyc in http_error_302(self, req, fp, code, msg, headers)
      623         fp.close()
      624 
  --&gt; 625         return self.parent.open(new, timeout=req.timeout)
      626 
      627     http_error_301 = http_error_303 = http_error_307 = http_error_302
  
  C:\Python27\lib\urllib2.pyc in open(self, fullurl, data, timeout)
      404         for processor in self.process_response.get(protocol, []):
      405             meth = getattr(processor, meth_name)
  --&gt; 406             response = meth(req, response)
      407 
      408         return response
  
  C:\Python27\lib\urllib2.pyc in http_response(self, request, response)
      517         if not (200 &lt;= code &lt; 300):
      518             response = self.parent.error(
  --&gt; 519                 'http', request, response, code, msg, hdrs)
      520 
      521         return response
  
  C:\Python27\lib\urllib2.pyc in error(self, proto, *args)
      442         if http_err:
      443             args = (dict, 'default', 'http_error_default') + orig_args
  --&gt; 444             return self._call_chain(*args)
      445 
      446 # XXX probably also want an abstract factory that knows when it makes
  
  C:\Python27\lib\urllib2.pyc in _call_chain(self, chain, kind, meth_name, *args)
      376             func = getattr(handler, meth_name)
      377 
  --&gt; 378             result = func(*args)
      379             if result is not None:
      380                 return result
  
  C:\Python27\lib\urllib2.pyc in http_error_default(self, req, fp, code, msg, hdrs)
      525 class HTTPDefaultErrorHandler(BaseHandler):
      526     def http_error_default(self, req, fp, code, msg, hdrs):
  --&gt; 527         raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
      528 
      529 class HTTPRedirectHandler(BaseHandler):
  
  HTTPError: HTTP Error 503: Service Unavailable
  </code></pre>