diff --git a/recipes/nytimes.recipe b/recipes/nytimes.recipe index 55f77237f6..7aa9893ba8 100644 --- a/recipes/nytimes.recipe +++ b/recipes/nytimes.recipe @@ -266,7 +266,15 @@ class NewYorkTimes(BasicNewsRecipe): if article.get('description'): self.log('\t\t', article['description']) - container = soup.find(id='collection-{}'.format(slug)).find('section') + cid = slug.split('/')[-1] + if cid == 'dining': + cid = 'food' + try: + container = soup.find(id='collection-{}'.format(cid)).find('section') + except AttributeError: + container = None + if container is None: + raise ValueError('Failed to find articles container for slug: {}'.format(slug)) for ol in container.findAll('ol'): for article in self.parse_article_group(ol): log(article) diff --git a/recipes/nytimes_sub.recipe b/recipes/nytimes_sub.recipe index 02ff62ba3d..9663e10218 100644 --- a/recipes/nytimes_sub.recipe +++ b/recipes/nytimes_sub.recipe @@ -266,7 +266,15 @@ class NewYorkTimes(BasicNewsRecipe): if article.get('description'): self.log('\t\t', article['description']) - container = soup.find(id='collection-{}'.format(slug)).find('section') + cid = slug.split('/')[-1] + if cid == 'dining': + cid = 'food' + try: + container = soup.find(id='collection-{}'.format(cid)).find('section') + except AttributeError: + container = None + if container is None: + raise ValueError('Failed to find articles container for slug: {}'.format(slug)) for ol in container.findAll('ol'): for article in self.parse_article_group(ol): log(article)