Skip to content

fix: replace the CNN exercise with EZ population#2295

Open
honzajavorek wants to merge 3 commits intomasterfrom
honzajavorek/cnn-fix
Open

fix: replace the CNN exercise with EZ population#2295
honzajavorek wants to merge 3 commits intomasterfrom
honzajavorek/cnn-fix

Conversation

@honzajavorek
Copy link
Collaborator

@honzajavorek honzajavorek commented Feb 27, 2026

Fix #2183


Note

Low Risk
Documentation/exercise content update plus new sample scripts; main risk is brittleness due to reliance on a third-party website structure and live network calls in tests.

Overview
Updates the JavaScript and Python “scraping variants” lessons to replace the CNN Sports shortest-article exercise with a new eurozone population exercise.

Removes the old CNN solution scripts and adds new eurozone_population implementations (Node/Cheerio and Python/httpx+BeautifulSoup) that crawl the EU euro-area country pages, extract Population, and print the summed total; corresponding bats tests are updated to run the new scripts and assert a plausible numeric result.

Written by Cursor Bugbot for commit 28be7a5. Configure here.

@honzajavorek honzajavorek requested a review from TC-MO as a code owner February 27, 2026 13:23
@honzajavorek honzajavorek added the t-academy Issues related to Web Scraping and Apify academies. label Feb 27, 2026
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Free Tier Details

Your team is on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle for each member of your team.

To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Comment @cursor review or bugbot run to trigger another review on this PR

for country_link in euro_countries_accordion.select("li a"):
country_url = urljoin(listing_url, country_link["href"])
country_soup = download(country_url)
total_population += parse_population(country_soup)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Python crashes when parse_population returns None

High Severity

parse_population is typed int | None and returns None when no li element contains "Population". The line total_population += parse_population(country_soup) will raise a TypeError if None is returned, since int + None is invalid in Python. The JavaScript version correctly handles this by filtering out non-integer values with .filter((population) => Number.isInteger(population)) before summing, but the Python version has no equivalent guard.

Additional Locations (1)

Fix in Cursor Fix in Web

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The exercise is naive to keep the code simple, so yeah, it relies on the target website a lot and it would crash, but the code is tested, so we'd know. Anyway, I'll add one line to make you happy.

@apify-service-account
Copy link

Preview for this PR was built for commit 28be7a5d and is ready at https://pr-2295.preview.docs.apify.com!

@apify-service-account
Copy link

Preview for this PR was built for commit b4e6d534 and is ready at https://pr-2295.preview.docs.apify.com!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

t-academy Issues related to Web Scraping and Apify academies.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Replace the 'finds the shortest CNN sports article' exercise

2 participants