From 6b6403c7e2a6086254ce8592ecb2468629203b03 Mon Sep 17 00:00:00 2001 From: unkn0w7n <51942695+unkn0w7n@users.noreply.github.com> Date: Tue, 1 Oct 2024 21:26:15 +0530 Subject: [PATCH] Update natgeomag.recipe --- recipes/natgeomag.recipe | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/recipes/natgeomag.recipe b/recipes/natgeomag.recipe index bf5661bb75d6..a009f653d030 100644 --- a/recipes/natgeomag.recipe +++ b/recipes/natgeomag.recipe @@ -208,11 +208,12 @@ class NatGeo(BasicNewsRecipe): articles = ans.setdefault(section, []) articles.append({'title': title, 'url': url}) for promo in soup.findAll(**classes('OneUpPromoCard__Content')): - url = promo.a['href'] - section = self.tag_to_string(promo.find(**classes('SectionLabel'))) - title = self.tag_to_string(promo.find(**classes('Card__Content__Heading'))) - articles = ans.setdefault(section, []) - articles.append({'title': title, 'url': url}) + if promo.find('a', attrs={'href': True}): + url = promo.a['href'] + section = self.tag_to_string(promo.find(**classes('SectionLabel'))) + title = self.tag_to_string(promo.find(**classes('Card__Content__Heading'))) + articles = ans.setdefault(section, []) + articles.append({'title': title, 'url': url}) for gird in soup.findAll(attrs={'class':'GridPromoTile'}): for article in soup.findAll('article'): a = article.find('a')