response = requests.get("http://words.bighugelabs.com/api/2/%s/%s/json"
                            % (self.tkey, word)).json()
        return response
975796
def getThesaurus(self, word):
        """"""
        response = requests.get(
            "http://api.wordnik.com:80/v4/word.json/%s/relatedWords?"
            "useCanonical=false&relationshipTypes=synonym&limitPer"
            "RelationshipType=15&api_key=%s" % (word, key)).json()
        try:
            return response[0]
        except IndexError:
            pass
434744
def json(self, **kwargs):
        
        try:
            return super(ScraperResponse, self).json(**kwargs)
        except ValueError as ve:
            raise ParseException(ve)
497065
def _query(self, ResponseGroup="Large", **kwargs):
        
        response = self.api.ItemSearch(ResponseGroup=ResponseGroup, **kwargs)
        root = objectify.fromstring(response)
        if (hasattr(root.Items.Request, 'Errors') and
                not hasattr(root.Items, 'Item')):
            code = root.Items.Request.Errors.Error.Code
            msg = root.Items.Request.Errors.Error.Message
            if code == 'AWS.ParameterOutOfRange':
                raise NoMorePages(msg)
            elif code == 'HTTP Error 503':
                raise RequestThrottled(
                    "Request Throttled Error: '{0}', '{1}'".format(code, msg))
            else:
                raise SearchException(
                    "Amazon Search Error: '{0}', '{1}'".format(code, msg))
        if hasattr(root.Items, 'TotalPages'):
            if root.Items.TotalPages == self.current_page:
                self.is_last_page = True
        return root
1326725
def get(self, res_path, timeout=10.):
	
		
		
		resp = requests.get(
			self.__res_uri(res_path),
			headers=self.__headers(),
			verify=False,
			auth=self.__auth(),
			timeout=timeout
		)
		return (
			resp.status_code,
			json.loads(resp.text) if resp.status_code == 200 else {}
		)
91152
async def get_json(self, url, timeout=30, astext=False, exceptions=False):
        """"""
        try:
            with async_timeout.timeout(timeout):
                res = await self._aio_session.get(url)
                if res.status != 200:
                    _LOGGER.error("QSUSB returned %s [%s]", res.status, url)
                    return None
                res_text = await res.text()
        except (aiohttp.client_exceptions.ClientError,
                asyncio.TimeoutError) as exc:
            if exceptions:
                raise exc
            return None

        if astext:
            return res_text

        try:
            return json.loads(res_text)
        except json.decoder.JSONDecodeError:
            if res_text.strip(" ") == "":
                return None
            _LOGGER.error("Could not decode %s [%s]", res_text, url)
752833
def _http_response(self, url, method, data=None, content_type=None,
                       schema=None, **kwargs):
        

        if schema is None:
            schema = self.schema_2

        header = {
            'content-type': content_type or 'application/json',
            'Accept': schema,
        }

        # Token specific part. We add the token in the header if necessary
        auth = self.auth
        token_required = auth.token_required
        token = auth.token
        desired_scope = auth.desired_scope
        scope = auth.scope

        if token_required:
            if not token or desired_scope != scope:
                logger.debug("Getting new token for scope: %s", desired_scope)
                auth.get_new_token()

            header['Authorization'] = 'Bearer %s' % self.auth.token

        if data and not content_type:
            data = json.dumps(data)

        path = url.format(**kwargs)
        logger.debug("%s %s", method.__name__.upper(), path)
        response = method(self.host + path,
                          data=data, headers=header, **self.method_kwargs)
        logger.debug("%s %s", response.status_code, response.reason)
        response.raise_for_status()

        return response
1017464
def get_on_tmdb(uri, **kwargs):
    
    kwargs['api_key'] = app.config['TMDB_API_KEY']
    response = requests_session.get((TMDB_API_URL + uri).encode('utf8'), params=kwargs)
    response.raise_for_status()
    return json.loads(response.text)
962938
def _get(self, path):
        
        url = self._get_url(path)
        try:
            response = urllib2.urlopen(url)
        except Exception as err:
            self.log.error("%s: %s", url, err)
            return False

        try:
            doc = json.load(response)
        except (TypeError, ValueError):
            self.log.error("Unable to parse response from Mesos as a"
                           " json object")
            return False

        return doc
473627
async def _get(self, key: Text) -> Dict[Text, Any]:
        

        try:
            with await self.pool as r:
                return ujson.loads(await r.get(self.register_key(key)))
        except (ValueError, TypeError):
            return {}
825433
def _http_call(self, url, method, data=None, **kwargs):
        
        response = self._http_response(url, method, data=data, **kwargs)
        if not response.content:
            return {}

        return response.json()
943005
def hget(self, key):
        
        data = self.r.hget(self.hash, key)
        if data is not None and not isinstance(data, str):
            data = str(self.r.hget(self.hash, key), 'utf-8')
        return data
1072785
def get(self, *args, **kwargs):
        

        self._parameters.query = kwargs.pop('query', {}) if len(args) == 0 else args[0]
        self._parameters.limit = kwargs.pop('limit', 10000)
        self._parameters.offset = kwargs.pop('offset', 0)
        self._parameters.fields = kwargs.pop('fields', kwargs.pop('fields', []))

        return self._get_response('GET', stream=kwargs.pop('stream', False))
401706
def request(self, req):
        
        data = json.dumps(req)
        req = urllib2.Request(self.url, data, self.headers)
        f = self.opener.open(req)
        resp = f.read()
        f.close()
        return json.loads(resp)
704468
def _get_json(self, model, space=None, rel_path=None, extra_params=None, get_all=None):
        
        # Only API.spaces and API.event should not provide
        # the `space argument
        if space is None and model not in (Space, Event):
            raise Exception(
                'In general, `API._get_json` should always '
                'be called with a `space` argument.'
            )

        if not extra_params:
            extra_params = {}

        # Handle pagination for requests carrying large amounts of data
        extra_params['page'] = extra_params.get('page', 1)

        # Generate the url to hit
        url = '{0}/{1}/{2}.json?{3}'.format(
            settings.API_ROOT_PATH,
            settings.API_VERSION,
            rel_path or model.rel_path,
            urllib.urlencode(extra_params),
        )

        # If the cache is being used and the url has been hit already
        if self.cache_responses and url in self.cache:
            response = self.cache[url]
        else:
            # Fetch the data
            headers = {
                'X-Api-Key': self.key,
                'X-Api-Secret': self.secret,
            }
            response = self.session.get(url=url, headers=headers)
            # If the cache is being used, update it
            if self.cache_responses:
                self.cache[url] = response

        if response.status_code == 200:  # OK
            results = []
            json_response = response.json()
            for obj in json_response:
                instance = model(data=obj)
                instance.api = self
                if space:
                    instance.space = space
                results.append(instance)
            # If it looks like there are more pages to fetch,
            # try and fetch the next one
            per_page = extra_params.get('per_page', None)
            if (
                get_all
                and per_page
                and len(json_response)
                and per_page == len(json_response)
            ):
                extra_params['page'] += 1
                results = results + self._get_json(model, space, rel_path, extra_params, get_all=get_all)
            return results
        elif response.status_code == 204:  # No Content
            return []
        else:  # Most likely a 404 Not Found
            raise Exception(
                'Code {0} returned from `{1}`. Response text: "{2}".'.format(
                    response.status_code,
                    url,
                    response.text
                )
            )
373460
def get(self, url):
        

        response = requests.get(
            self.host + url,
            headers={
                'Authorization': 'Bearer ' + self.token,
                'x-falkonry-source':self.sourceHeader
            },
            verify=False
        )
        if response.status_code == 200:
            try:
                return json.loads(response._content.decode('utf-8'))
            except Exception as error:
                return response.content
        elif response.status_code == 401:
            raise Exception(json.dumps({'message':'Unauthorized Access'}))
        else:
            raise Exception(response.content)
593662
def get_json_results(self, response):
        '''
        
        '''
        try:
            # return the proper JSON object, or error code if request didn't go through.
            self.most_recent_json = response.json()
            json_results = response.json()
            if response.status_code in [401, 403]: #401 is invalid key, 403 is out of monthly quota.
                raise PyMsCognitiveWebSearchException("CODE {code}: {message}".format(code=response.status_code,message=json_results["message"]) )
            elif response.status_code in [429]: #429 means try again in x seconds.
                message = json_results['message']
                try:
                    # extract time out seconds from response
                    timeout = int(re.search('in (.+?) seconds', message).group(1)) + 1
                    print ("CODE 429, sleeping for {timeout} seconds").format(timeout=str(timeout))
                    time.sleep(timeout)
                except (AttributeError, ValueError) as e:
                    if not self.silent_fail:
                        raise PyMsCognitiveWebSearchException("CODE 429. Failed to auto-sleep: {message}".format(code=response.status_code,message=json_results["message"]) )
                    else:
                        print ("CODE 429. Failed to auto-sleep: {message}. Trying again in 5 seconds.".format(code=response.status_code,message=json_results["message"]))
                        time.sleep(5)
        except ValueError as vE:
            if not self.silent_fail:
                raise PyMsCognitiveWebSearchException("Request returned with code %s, error msg: %s" % (r.status_code, r.text))
            else:
                print ("[ERROR] Request returned with code %s, error msg: %s. \nContinuing in 5 seconds." % (r.status_code, r.text))
                time.sleep(5)
        return json_results
1055420
def request(self, method, resource, params=None):
        

        url = self.get_url(resource, params)

        # headers

        headers = {
            'Content-Type': 'application/json'
        }

        auth = requests.auth.HTTPBasicAuth(self.username, self.password)

        # request

        log.info('Request to %s. Data: %s' % (url, params))

        response = requests.request(method, url, data=json.dumps(params), headers=headers, auth=auth)
        response.raise_for_status()

        # response

        log.info('Response from %s: %s' % (url, response.text))
        content = response.json()

        self.parse_status(content.get('status'))

        return content