def getFeed(url, params=None, request_hook=None): try: response = request_hook(url, params=params, timeout=30) if not response: raise Exception feed = parse(response.text, response_headers={'content-type': 'application/xml'}) if feed: if 'entries' in feed: return feed elif 'error' in feed.feed: err_code = feed.feed['error']['code'] err_desc = feed.feed['error']['description'] log.debug(u'RSS ERROR:[{error}] CODE:[{code}]', { 'error': err_desc, 'code': err_code }) else: log.debug(u'RSS error loading data: {}', url) except Exception as e: log.debug(u'RSS error: {}', ex(e)) return {'entries': []}
def getFeed(url, request_headers=None, handlers=None): url = normalize_url(url) try: try: feed = parse(url, False, False, request_headers, handlers=handlers) feed[b'entries'] return feed except AttributeError: logging.debug('RSS ERROR:[{}] CODE:[{}]'.format( feed.feed[b'error'][b'description'], feed.feed[b'error'][b'code'])) except:pass
def getFeed(url, request_headers=None, handlers=None): url = normalize_url(url) try: try: feed = parse(url, False, False, request_headers, handlers=handlers) feed[b'entries'] return feed except AttributeError: logging.debug('RSS ERROR:[{}] CODE:[{}]'.format( feed.feed[b'error'][b'description'], feed.feed[b'error'][b'code'])) except: pass
def getFeed(url, params=None, request_hook=None): try: data = request_hook(url, params=params, returns='text', timeout=30) if not data: raise feed = parse(data, response_headers={'content-type': 'application/xml'}) if feed: if 'entries' in feed: return feed elif 'error' in feed.feed: err_code = feed.feed['error']['code'] err_desc = feed.feed['error']['description'] logger.log(u'RSS ERROR:[{0!s}] CODE:[{1!s}]'.format(err_desc, err_code), logger.DEBUG) else: logger.log(u'RSS error loading data: ' + url, logger.DEBUG) except Exception as e: logger.log(u'RSS error: ' + ex(e), logger.DEBUG) return {'entries': []}
def getFeed(url, request_headers=None, handlers=None): parsed = list(urlparse.urlparse(url)) parsed[2] = re.sub("/{2,}", "/", parsed[2]) # replace two or more / with one try: feed = parse(url, False, False, request_headers, handlers=handlers) if feed: if 'entries' in feed: return feed elif 'error' in feed.feed: err_code = feed.feed['error']['code'] err_desc = feed.feed['error']['description'] logger.log(u'RSS ERROR:[%s] CODE:[%s]' % (err_desc, err_code), logger.DEBUG) else: logger.log(u'RSS error loading url: ' + url, logger.DEBUG) except Exception as e: logger.log(u'RSS error: ' + ex(e), logger.DEBUG) return FeedParserDict()
def getFeed(url, params=None, request_hook=None): try: response = request_hook(url, params=params, timeout=30) if not response: raise Exception feed = parse(response.text, response_headers={'content-type': 'application/xml'}) if feed: if 'entries' in feed: return feed elif 'error' in feed.feed: err_code = feed.feed['error']['code'] err_desc = feed.feed['error']['description'] log.debug(u'RSS ERROR:[{error}] CODE:[{code}]', {'error': err_desc, 'code': err_code}) else: log.debug(u'RSS error loading data: {}', url) except Exception as e: log.debug(u'RSS error: {}', ex(e)) return {'entries': []}