feat: Expose `use_state` in `BasicCrawler` by Mantisus · Pull Request #1799 · apify/crawlee-python
Navigation Menu
{{ message }}
apify / crawlee-python Public
- Notifications You must be signed in to change notification settings
- Fork 705
Merged
feat: Expose use_state in BasicCrawler#1799
vdusek merged 1 commit intoapify:masterfrom
feat: Expose use_state in BasicCrawler#1799
vdusek merged 1 commit intoapify:masterfrom
Conversation
Copy link
Collaborator
Mantisus
commented
Mar 19, 2026
Mantisus
commented
Description
- Expose
use_stateinBasicCrawler. This can be useful for passing data initialized during crawler setup into a handler.
Example:
async def main(): crawler = BasicCrawler() await crawler.use_state({'state': 'init'}) @crawler.router.default_handler async def handler(context): data = await context.use_state() context.log.info(f'State: {data["state"]}') await crawler.run(["https://www.example.com/"]) if __name__ == '__main__': asyncio.run(main())
Mantisus
self-assigned this
vdusek approved these changes Mar 19, 2026
Copy link
Collaborator
vdusek
left a comment
vdusek
left a comment
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, all other Crawlers have it exposed, am I correct?
Copy link
Collaborator Author
Mantisus
commented
Mar 19, 2026
Mantisus commented
Mar 19, 2026all other Crawlers have it exposed, am I correct?
After that PR method will be exposed in all crawlers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment