refactor: change Academy code examples to use Crawlee router#2293
refactor: change Academy code examples to use Crawlee router#2293honzajavorek merged 2 commits intomasterfrom
Conversation
Fix #2181 Address #2097 (comment) by @B4nan
|
Preview for this PR was built for commit |
There was a problem hiding this comment.
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 labeledaddHandler()routes. - Refactor
crawlee_f1_drivers.mjsandcrawlee_netflix_ratings.mjsexercise 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. |
sources/academy/webscraping/scraping_basics_javascript/exercises/crawlee_f1_drivers.mjs
Show resolved
Hide resolved
sources/academy/webscraping/scraping_basics_javascript/exercises/crawlee_netflix_ratings.mjs
Show resolved
Hide resolved
sources/academy/webscraping/scraping_basics_javascript/exercises/crawlee_netflix_ratings.mjs
Show resolved
Hide resolved
|
Preview for this PR was built for commit |
B4nan
left a comment
There was a problem hiding this comment.
did you change the indents on purpose? (4 -> 2 spaces)
sources/academy/webscraping/scraping_basics_javascript/12_framework.md
Outdated
Show resolved
Hide resolved
sources/academy/webscraping/scraping_basics_javascript/12_framework.md
Outdated
Show resolved
Hide resolved
sources/academy/webscraping/scraping_basics_javascript/12_framework.md
Outdated
Show resolved
Hide resolved
sources/academy/webscraping/scraping_basics_javascript/12_framework.md
Outdated
Show resolved
Hide resolved
5ff2b51 to
41d7ed0
Compare
|
Preview for this PR was built for commit |
41d7ed0 to
1aa2eb6
Compare
|
Preview for this PR was built for commit |
|
@B4nan Thanks for the review! Without the missing awaits the examples couldn't work 🤦♂️ I hope it's all fixed now. |
|
Preview for this PR was built for commit |
B4nan
left a comment
There was a problem hiding this comment.
Btw not sure if you're into agentic development, but it would be great to let an agent read through all the tutorials and actually try them locally, this approach worked great for me. If you don't have any claude/codex/whatever subscription, someone from Apify could run this.
|
I have a subscription, but not a big one. I guess this would drain my tokens really fast. @TC-MO do you think you could do this? We could have it as a side quest to improve the docs, similar to the PRs from @mtrunkat, but I'd be cautious about reviewing the work it will generate, so we better split this into self-contained fix PRs. |
Fix #2181, address #2097 (comment) by @B4nan
Note
Low Risk
Low risk documentation/exercise refactor that changes sample code structure to the newer Crawlee
routerAPI without altering the scraping behavior.Overview
Refactors the Crawlee lesson (
12_framework.md) to constructCheerioCrawlerwithout an inlinerequestHandlerand instead register routing viacrawler.router.addDefaultHandler()plus labeledaddHandler()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, removingrequest.labelbranching 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.