def getUrl(url): try: req = urllib2.Request(urlHost+url) req.add_header('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3') req.add_header('Accept-encoding', 'gzip') token_data = contact.do_token(url) req.add_header('BS-Token',token_data) response = urllib2.urlopen(req) if response.info().get('Content-Encoding') == 'gzip': d = zlib.decompressobj(16+zlib.MAX_WBITS) return d.decompress(response.read()) else: return response.read() response.close() except: return False