Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore no programme information #497

Merged
merged 1 commit into from
Sep 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion server/scraper/urgentfm.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ def get_programme():


def get_programme_description(link):
if link is None:
return None, None
response = retry_session.get(link)
soup = BeautifulSoup(response.text, 'html.parser')
image_element = soup.select_one("body > div.content > div > div > div.col-3.col-md-auto > img")
Expand All @@ -45,7 +47,12 @@ def run(output):
os.makedirs(output_path, exist_ok=True) # Like mkdir -p
output_file = os.path.join(output_path, 'status.json') # Output file

programme, programme_link = get_programme()
try:
programme, programme_link = get_programme()
except AttributeError:
# The site is flaky again and I am tired of the mails.
programme, programme_link = "Onbekend", None

try:
programme_image, programme_description = get_programme_description(programme_link)
except IndexError:
Expand Down
Loading