Skip to content

refactor: change Academy code examples to use Crawlee router#2293

Open
honzajavorek wants to merge 2 commits intomasterfrom
honzajavorek/router
Open

refactor: change Academy code examples to use Crawlee router#2293
honzajavorek wants to merge 2 commits intomasterfrom
honzajavorek/router

Conversation

@honzajavorek
Copy link
Collaborator

@honzajavorek honzajavorek commented Feb 27, 2026

Fix #2181, address #2097 (comment) by @B4nan


Note

Low Risk
Low risk documentation/exercise refactor that changes sample code structure to the newer Crawlee router API without altering the scraping behavior.

Overview
Refactors the Crawlee lesson (12_framework.md) to construct CheerioCrawler without an inline requestHandler and instead register routing via crawler.router.addDefaultHandler() plus labeled addHandler() functions (e.g. DETAIL, IMDB_SEARCH, IMDB).

Updates the associated exercise solutions (crawlee_f1_drivers.mjs, crawlee_netflix_ratings.mjs) to match the router-based pattern, removing request.label branching and splitting listing/search/detail logic into dedicated handlers while keeping the same data extraction and dataset export steps.

Written by Cursor Bugbot for commit 1aa2eb6. Configure here.

@honzajavorek honzajavorek added the t-academy Issues related to Web Scraping and Apify academies. label Feb 27, 2026
@honzajavorek honzajavorek requested a review from TC-MO as a code owner February 27, 2026 10:20
@honzajavorek honzajavorek changed the title refactor: use router refactor: use Crawlee router Feb 27, 2026
@honzajavorek honzajavorek changed the title refactor: use Crawlee router refactor: change Academy code examples to use Crawlee router Feb 27, 2026
@apify-service-account
Copy link

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

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Refactors the JavaScript Academy “Using a framework” lesson and its two associated Crawlee exercise solutions to use a router-based request handling structure instead of request.label branching inside a single inline requestHandler.

Changes:

  • Update lesson code examples to register handlers via addDefaultHandler() and labeled addHandler() routes.
  • Refactor crawlee_f1_drivers.mjs and crawlee_netflix_ratings.mjs exercise solutions to split logic into dedicated router handlers.
  • Minor variable naming adjustment in the Netflix/IMDb exercise handler logic.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
sources/academy/webscraping/scraping_basics_javascript/exercises/crawlee_netflix_ratings.mjs Refactors the Netflix → IMDb workflow to router handlers (default, IMDB_SEARCH, IMDB).
sources/academy/webscraping/scraping_basics_javascript/exercises/crawlee_f1_drivers.mjs Refactors listing vs. detail handling into router default + DRIVER handler.
sources/academy/webscraping/scraping_basics_javascript/12_framework.md Updates lesson narrative and snippets to demonstrate the router-based approach.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@apify-service-account
Copy link

Preview for this PR was built for commit 5ff2b518 and is ready at https://pr-2293.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.

Use Crawlee router in the framework lesson of the JS course

3 participants