def get_gifs_by_keyword(self, keyword, offset=0, count=40, dont_parse=False): if not dont_parse: #Pick the most gif friendly keyword available keyword = LyricParser.get_keyword(keyword) params = {'api_key': self.api_key} params['q'] = keyword params['limit'] = count params['offset'] = offset search_request_url = "%s?%s" % (self.search_by_keyword_endpoint, urllib.urlencode(params)) try: return simplejson.loads(requests.get(search_request_url, timeout=5).text) except Exception: return {}