ParselCrawlingContext
Hierarchy
- ParsedHttpCrawlingContext
- ParselCrawlingContext
Index
Methods
Properties
Methods
__hash__
Return hash of the context. Each context is considered unique.
Returns int
create_modified_copy
Create a modified copy of the crawling context with specified changes.
Parameters
optionalpush_data: PushDataFunction | None = None
optionaladd_requests: AddRequestsFunction | None = None
optionalget_key_value_store: GetKeyValueStoreFromRequestHandlerFunction | None = None
Returns Self
extract_form_requests
Create requests submitting the forms matching
selectorthe way a browser does.By default, only one form is submitted: the first one a browser can submit among those sharing the most field names with
fields.Parameters
optionalkeyword-onlyselector: str = 'form'
CSS selector for the forms. An invalid one matches no form.
optionalkeyword-onlyfields: Mapping[str, (str | Sequence[str]) | None] | None = None
Values replacing the form fields or adding new ones. A
Nonevalue drops the field and a sequence submits it once per value. Withall_forms, only the fields a form has are replaced.optionalkeyword-onlyclick: bool | Mapping[str, str] = True
The submit button to click:
Truefor the first enabled one, if any,Falsefor none, or a mapping of attributes the button must have, disabled or not, which skips forms without such a button.optionalkeyword-onlyall_forms: bool = False
Submit each matching form instead of only one.
keyword-onlyoptionallabel: str | None
A label routing the request to a specific handler.
keyword-onlyoptionalheaders: (HttpHeaders | dict[str, str]) | None
HTTP headers of the request, replacing those the form sets, like
Content-TypeorReferer.keyword-onlyoptionalsession_id: str | None
ID of the
Sessionthe request is bound to.keyword-onlyoptionalkeep_url_fragment: bool
Whether the URL fragment counts towards the unique key of the request.
keyword-onlyoptionaluse_extended_unique_key: bool
Whether the method and payload count towards the unique key. Defaults to
Truefor POST forms.keyword-onlyoptionalalways_enqueue: bool
Whether to enqueue the request even if it's already in the queue.
keyword-onlyoptionaluser_data: Mapping[str, JsonSerializable]
Custom data stored with the request.
keyword-onlyoptionalno_retry: bool
Whether to skip retrying the request if it fails.
keyword-onlyoptionalmax_retries: int | None
The maximum number of retries of the request.
Returns list[Request]
from_basic_crawling_context
Initialize a new instance from an existing
BasicCrawlingContext.Parameters
context: BasicCrawlingContext
http_response: HttpResponse
Returns Self
from_http_crawling_context
Initialize a new instance from an existing
HttpCrawlingContext.Parameters
context: HttpCrawlingContext
parsed_content: TParseResult
enqueue_links: EnqueueLinksFunction
extract_links: ExtractLinksFunction
Returns Self
from_parsed_http_crawling_context
Create a new context from an existing
ParsedHttpCrawlingContext[Selector].Parameters
context: ParsedHttpCrawlingContext[Selector]
Returns Self
get_snapshot
Get snapshot of crawled page.
Returns PageSnapshot
html_to_text
Convert the parsed HTML content to newline-separated plain text without tags.
Returns str
Properties
add_requests
Add requests crawling context helper function.
enqueue_links
extract_links
get_key_value_store
Get key-value store crawling context helper function.
http_response
The HTTP response received from the server.
log
Logger instance.
parsed_content
proxy_info
Proxy information for the current page being processed.
push_data
Push data crawling context helper function.
register_deferred_cleanup
Register an async callback to be called after request processing completes (including error handlers).
request
Request object for the current page being processed.
selector
Convenience alias.
send_request
Send request crawling context helper function.
session
Session object for the current page being processed.
use_state
Use state crawling context helper function.
The crawling context used by the
ParselCrawler.It provides access to key objects as well as utility functions for handling crawling tasks.