File tree Expand file tree Collapse file tree
docs/guides/code_examples/http_crawlers Expand file tree Collapse file tree Original file line number Diff line number Diff line change 66from crawlee .crawlers ._abstract_http import ParsedHttpCrawlingContext
77
88
9+ # Custom context for Selectolax parser, you can add your own methods here
10+ # to facilitate working with the parsed document.
911@dataclass (frozen = True )
1012class SelectolaxLexborContext (ParsedHttpCrawlingContext [LexborHTMLParser ]):
1113 """Crawling context providing access to the parsed page.
Original file line number Diff line number Diff line change 1717 from crawlee .crawlers ._abstract_http import ParsedHttpCrawlingContext
1818
1919
20+ # Custom crawler using custom context, It is optional and you can use
21+ # AbstractHttpCrawler directly with SelectolaxLexborParser if you don't need
22+ # any custom context methods.
2023class SelectolaxLexborCrawler (
2124 AbstractHttpCrawler [SelectolaxLexborContext , LexborHTMLParser , LexborNode ]
2225):
@@ -30,6 +33,8 @@ def __init__(
3033 async def final_step (
3134 context : ParsedHttpCrawlingContext [LexborHTMLParser ],
3235 ) -> AsyncGenerator [SelectolaxLexborContext , None ]:
36+ # Yield custom context wrapping with additional functionality around the base
37+ # context.
3338 yield SelectolaxLexborContext .from_parsed_http_crawling_context (context )
3439
3540 # Build context pipeline: HTTP request -> parsing -> custom context.
You can’t perform that action at this time.
0 commit comments