+
    }iC                       ^ RI Ht ^ RIHtHt ^ RIHt ^ RIHt ^ RIH	t	H
t
HtHtHt ^ RIHtHtHtHtHtHtHt ^ RIHt ^ RIHtHtHtHtHt ^ R	IHt ^ R
I H!t! ^ RI"H#t# ^ RI$H%t% ]	'       d   ^ RI&H't'H(t(H)t)  ! R R]4      t* ! R R]4      t+ ! R R]]],]3,          4      t-]! ]-4      t.]!! R4       ! R R]4      4       t/]!! R4       ! R R]4      4       t0 ! R R]04      t1R# )    )annotations)IteratorMutableMapping)datetime)IntEnum)TYPE_CHECKING	AnnotatedAny	TypedDictcast)	BaseModelBeforeValidator
ConfigDictFieldPlainSerializerPlainValidatorTypeAdapter)URL)EnqueueStrategyHttpHeaders
HttpMethodHttpPayloadJsonSerializable)crypto_random_object_id)
docs_group)compute_unique_key)validate_http_url)NotRequiredRequiredSelfc                  :    ] tR t^tRt^ t^t^t^t^t	^t
^t^tRtR# )RequestState(Crawlee-specific request handling state. N)__name__
__module____qualname____firstlineno____doc__UNPROCESSED
BEFORE_NAV	AFTER_NAVREQUEST_HANDLERDONEERROR_HANDLERERRORSKIPPED__static_attributes__r$       b/Users/ahmad/.openclaw/workspace/my-crawler/.venv/lib/python3.14/site-packages/crawlee/_request.pyr"   r"      s-    2KJIODMEGr3   r"   c                      ] tR t^"t$ RtRtR]R&    RtR]R&    ]P                  t
R]R&    RtR	]R
&    RtR]R&   RtR]R&    RtR]R&    ^ tR]R&    RtR]R&   RtR# )CrawleeRequestData9Crawlee-specific configuration stored in the `user_data`.Nz=Annotated[int | None, Field(alias='maxRetries', frozen=True)]max_retrieszAAnnotated[EnqueueStrategy | None, Field(alias='enqueueStrategy')]enqueue_strategyr"   statez:Annotated[int | None, Field(alias='sessionRotationCount')]session_rotation_countFz.Annotated[bool, Field(alias='skipNavigation')]skip_navigationz3Annotated[int | None, Field(alias='lastProxyTier')]last_proxy_tierzAnnotated[bool, Field()]	forefrontz)Annotated[int, Field(alias='crawlDepth')]crawl_depthAnnotated[str | None, Field()]
session_idr$   )r%   r&   r'   r(   r)   r8   __annotations__r9   r"   r*   r:   r;   r<   r=   r>   r?   rA   r2   r$   r3   r4   r6   r6   "   s    CQUKNU [_W^?&22E<2:Y]V]DFKOCKKOOHO:*/I'/T=>K:>515J.58r3   r6   c                     a  ] tR t^At$ Rt]! RR7      t]! RR7      tR]	R&   Rt
R	]	R
&    RtR]	R&    R R ltR R ltR R ltR R ltR R ltR V 3R lltR R ltRtV ;t# )UserDatazRepresents the `user_data` part of a Request.

Apart from the well-known attributes (`label` and `__crawlee`), it can also contain arbitrary JSON-compatible
values.
allow)extraF)initdict[str, JsonSerializable]__pydantic_extra__Nz>Annotated[CrawleeRequestData | None, Field(alias='__crawlee')]crawlee_datar@   labelc                    V ^8  d   QhRRRR/# )   keystrreturnr   r$   )formats   "r4   __annotate__UserData.__annotate__Q   s     , ,s ,'7 ,r3   c                	(    V P                   V,          # NrI   selfrN   s   &&r4   __getitem__UserData.__getitem__Q   s    &&s++r3   c               $    V ^8  d   QhRRRRRR/# )rM   rN   rO   valuer   rP   Noner$   )rQ   s   "r4   rR   rS   T   s"     - -s -+; - -r3   c                	    VR 8X  d,   Ve"   \        V\        4      '       g   \        R4      hW n        W P                  V&   R# )rK   Nz`label` must be str or None)
isinstancerO   
ValueErrorrK   rI   )rX   rN   r\   s   &&&r4   __setitem__UserData.__setitem__T   s:    '> E3)?)? !>??J',$r3   c                    V ^8  d   QhRRRR/# )rM   rN   rO   rP   r]   r$   )rQ   s   "r4   rR   rS   ]   s     ) )s )t )r3   c                	     V P                   V R # rU   rV   rW   s   &&r4   __delitem__UserData.__delitem__]   s    ##C(r3   c                   V ^8  d   QhRR/# )rM   rP   zIterator[str]r$   )rQ   s   "r4   rR   rS   `   s     + +- +r3   c              #  	:   "   V P                    R j  xL
  R #  L5irU   rV   rX   s   &r4   __iter__UserData.__iter__`   s     ****s   c                   V ^8  d   QhRR/# rM   rP   intr$   )rQ   s   "r4   rR   rS   c   s     , , ,r3   c                	,    \        V P                  4      # rU   )lenrI   ri   s   &r4   __len__UserData.__len__c   s    4**++r3   c                    V ^8  d   QhRRRR/# )rM   otherobjectrP   boolr$   )rQ   s   "r4   rR   rS   f   s      F t r3   c                	   < \        V\        4      '       d   \        SV `  V4      # \        V\        4      '       d   V P                  4       V8H  # \        # rU   )r_   r   super__eq__dict
model_dumpNotImplemented)rX   rt   	__class__s   &&r4   ry   UserData.__eq__f   sD    eY''7>%((eT""??$--r3   c                   V ^8  d   QhRR/# rm   r$   )rQ   s   "r4   rR   rS   o   s     1 1# 1r3   c                x    V P                  4       p\        \        \        VP	                  4       4      4      4      # )z&Return hash based on the model fields.)r{   hashtuplesorteditems)rX   datas   & r4   __hash__UserData.__hash__o   s)     E&./00r3   )rK   )r%   r&   r'   r(   r)   r   model_configr   rI   rB   rJ   rK   rY   ra   re   rj   rq   ry   r   r2   __classcell__)r}   s   @r4   rD   rD   A   sn     G,L6;6G3GSWLPWC,0E)0),-)+, 1 1r3   rD   Otherc                      ] tR t^xt$ RtR]R&   R]R&   R]R&   R]R	&   R
]R&   R
]R&   R
]R&   R
]R&   R]R&   R]R&   R]R&   R]R&   R]R&   R]R&   R]R&   RtR# )RequestOptionszOptions that can be used to customize request creation.

This type exactly matches the parameters of `Request.from_url` method.
zRequired[str]urlzNotRequired[HttpMethod]methodz0NotRequired[HttpHeaders | dict[str, str] | None]headersz%NotRequired[HttpPayload | str | None]payloadzNotRequired[str | None]rK   rA   
unique_keyidzNotRequired[bool]keep_url_fragmentuse_extended_unique_keyalways_enqueuez(NotRequired[dict[str, JsonSerializable]]	user_datano_retryzNotRequired[EnqueueStrategy]r9   zNotRequired[int | None]r8   r$   Nr%   r&   r'   r(   r)   rB   r2   r$   r3   r4   r   r   x   sc    
 
##==22""''''((..%%7722((r3   r   zStorage datac                  H  a  ] tR t^t0 o $ Rt]! RRR7      tR]R&    R]R&    RtR	]R
&    Rt	R]R&    ]
'       d   ]! 4       tR]R&    / tR]R&   MR]R&    R]R&    ^ tR]R&    RtR]R&    RtR]R&    RtR]R&    ]R
RRRRRRRRRRRRRR RR!RR"RR#R/R$ R% ll4       tR&R/R' R( llt]R) R* l4       t]R+ R, l4       t]R- R. l4       t]R/ R0 l4       t]P4                  R1 R2 l4       t]R3 R4 l4       t]P4                  R5 R6 l4       t]R7 R8 l4       t]R9 R: l4       t]P4                  R; R< l4       t]R= R> l4       t]P4                  R? R@ l4       t]RA RB l4       t]P4                  RC RD l4       t]RE RF l4       t ] P4                  RG RH l4       t ]RI RJ l4       t!RKt"R# )LRequesta+  Represents a request in the Crawlee framework, containing the necessary information for crawling operations.

The `Request` class is one of the core components in Crawlee, utilized by various components such as request
providers, HTTP clients, crawlers, and more. It encapsulates the essential data for executing web requests,
including the URL, HTTP method, headers, payload, and user data. The user data allows custom information
to be stored and persisted throughout the request lifecycle, including its retries.

Key functionalities include managing the request's identifier (`id`), unique key (`unique_key`) that is used
for request deduplication, controlling retries, handling state management, and enabling configuration for session
rotation and proxy handling.

The recommended way to create a new instance is by using the `Request.from_url` constructor, which automatically
generates a unique key and identifier based on the URL and request parameters.

### Usage

```python
from crawlee import Request

request = Request.from_url('https://crawlee.dev')
```
T)validate_by_namevalidate_by_aliasz5Annotated[str, Field(alias='uniqueKey', frozen=True)]r   zFAnnotated[str, BeforeValidator(validate_http_url), Field(frozen=True)]r   GETz)Annotated[HttpMethod, Field(frozen=True)]r   NzAnnotated[HttpPayload | None, BeforeValidator(lambda v: v.encode() if isinstance(v, str) else v), PlainSerializer(lambda v: v.decode() if isinstance(v, bytes) else v), Field(frozen=True)]r   r   r   rH   r   z:Annotated[HttpHeaders, Field(default_factory=HttpHeaders)]a%  Annotated[dict[str, JsonSerializable], Field(alias='userData', default_factory=UserData), PlainValidator(user_data_adapter.validate_python), PlainSerializer(lambda instance: user_data_adapter.dump_python(instance, by_alias=True, exclude_none=False, exclude_unset=True, exclude_defaults=True))]z)Annotated[int, Field(alias='retryCount')]retry_countFz'Annotated[bool, Field(alias='noRetry')]r   zSAnnotated[str | None, BeforeValidator(validate_http_url), Field(alias='loadedUrl')]
loaded_urlz4Annotated[datetime | None, Field(alias='handledAt')]
handled_atrK   rA   r   r   r   r9   r8   c               P    V ^8  d   QhRRRRRRRRR	R
RR
RR
RRRRRRRRRRRRRR/# )rM   r   rO   r   r   r   z#HttpHeaders | dict[str, str] | Noner   zHttpPayload | str | NonerK   
str | NonerA   r   r   rv   r   r   r9   zEnqueueStrategy | Noner8   
int | Nonekwargsr
   rP   r    r$   )rQ   s   "r4   rR   Request.__annotate__   s     c cc 	c
 5c *c c c c  c "&c c 1c  c c  
!cr3   c               h   Ve   V
'       d   \        R4      h\        V\        4      '       g   Vf   \        T;'       g    / 4      p\        V\        4      '       d   VP                  4       pT;'       g    \        VVVVVVV	R7      pV
'       d   \        4        RV 2pVP                  R/ 4      ;'       g    / pVP                  R/ 4      pVe   WR&   Ve   WR&   \        R/ VB pV'       d   VVR&   V ! RRVR	VR
VRVRVRV/VB pVe   VVP                  R&   Ve   VVP                  n        V# )a  Create a new `Request` instance from a URL.

This is recommended constructor for creating new `Request` instances. It generates a `Request` object from
a given URL with additional options to customize HTTP method, payload, unique key, and other request
properties. If no `unique_key` or `id` is provided, they are computed automatically based on the URL,
method and payload. It depends on the `keep_url_fragment` and `use_extended_unique_key` flags.

Args:
    url: The URL of the request.
    method: The HTTP method of the request.
    headers: The HTTP headers of the request.
    payload: The data to be sent as the request body. Typically used with 'POST' or 'PUT' requests.
    label: A custom label to differentiate between request types. This is stored in `user_data`, and it is
        used for request routing (different requests go to different handlers).
    session_id: ID of a specific `Session` to which the request will be strictly bound.
        If the session becomes unavailable when the request is processed, a `RequestCollisionError` will be
        raised.
    unique_key: A unique key identifying the request. If not provided, it is automatically computed based on
        the URL and other parameters. Requests with the same `unique_key` are treated as identical.
    keep_url_fragment: Determines whether the URL fragment (e.g., `#section`) should be included in
        the `unique_key` computation. This is only relevant when `unique_key` is not provided.
    use_extended_unique_key: Determines whether to include the HTTP method, ID Session and payload in the
        `unique_key` computation. This is only relevant when `unique_key` is not provided.
    always_enqueue: If set to `True`, the request will be enqueued even if it is already present in the queue.
        Using this is not allowed when a custom `unique_key` is also provided and will result in a `ValueError`.
    enqueue_strategy: The strategy that will be used for enqueuing the request.
    max_retries: Maximum number of retries for this request. Allows to override the global `max_request_retries`
        option of `BasicCrawler`.
    **kwargs: Additional request properties.
z:`always_enqueue` cannot be used with a custom `unique_key`)r   r   r   rA   r   r   |r   	__crawlee
maxRetriesenqueueStrategyr   r   r   r   r   rK   r$   )r`   r_   rz   r   rO   encoder   r   popgetr6   r   rJ   rA   )clsr   r   r   r   rK   rA   r   r   r   r   r9   r8   r   user_data_dictcrawlee_data_dictrJ   requests   &&$$$$$$$$$$$,    r4   from_urlRequest.from_url   sx   ` !nYZZgt$$!'--R0Ggs##nn&G 
 
#5!/$;$

 356a
|DJK4::*..{B?".9l+'3C/0)>,=>*6N;' 

!
 
 	

 
 %
 
 ).Gg&!.8G  +r3   defaultc               $    V ^8  d   QhRRRRRR/# )rM   paramrO   r   r   rP   r$   )rQ   s   "r4   rR   r   X  s"     0 0c 0z 0U_ 0r3   c               b    \        V P                  4      P                  pVP                  W4      # )z9Get the value of a specific query parameter from the URL.)r   r   queryr   )rX   r   r   query_paramss   &&$ r4   get_query_param_from_url Request.get_query_param_from_urlX  s&    488}**//r3   c                   V ^8  d   QhRR/# rM   rP   r   r$   )rQ   s   "r4   rR   r   ^  s     6 6z 6r3   c                B    \        RV P                  4      P                  # )z?A string used to differentiate between arbitrary request types.rD   )r   r   rK   ri   s   &r4   rK   Request.label]  s     J/555r3   c                   V ^8  d   QhRR/# r   r$   )rQ   s   "r4   rR   r   c  s     , ,J ,r3   c                .    V P                   P                  # )z-The ID of the bound session, if there is any.)rJ   rA   ri   s   &r4   rA   Request.session_idb  s       +++r3   c                   V ^8  d   QhRR/# )rM   rP   r6   r$   )rQ   s   "r4   rR   r   h  s     & &0 &r3   c                    \        RV P                  4      pVP                  f   \        4       Vn        VP                  # )r7   rD   )r   r   rJ   r6   )rX   r   s   & r4   rJ   Request.crawlee_datag  s7     T^^4	!!)%7%9I"%%%r3   c                   V ^8  d   QhRR/# rm   r$   )rQ   s   "r4   rR   r   q  s     - -S -r3   c                .    V P                   P                  # )z+The depth of the request in the crawl tree.rJ   r?   ri   s   &r4   r?   Request.crawl_depthp         ,,,r3   c                    V ^8  d   QhRRRR/# rM   	new_valuern   rP   r]   r$   )rQ   s   "r4   rR   r   v  s     2 2S 2T 2r3   c                	&    WP                   n        R # rU   r   rX   r   s   &&r4   r?   r   u  s    (1%r3   c                   V ^8  d   QhRR/# )rM   rP   r"   r$   )rQ   s   "r4   rR   r   z  s     ' '| 'r3   c                .    V P                   P                  # )r#   rJ   r:   ri   s   &r4   r:   Request.statey  s       &&&r3   c                    V ^8  d   QhRRRR/# )rM   	new_stater"   rP   r]   r$   )rQ   s   "r4   rR   r     s     , ,| , ,r3   c                	&    WP                   n        R # rU   r   )rX   r   s   &&r4   r:   r   ~  s    "+r3   c                   V ^8  d   QhRR/# rM   rP   r   r$   )rQ   s   "r4   rR   r     s     - -Z -r3   c                .    V P                   P                  # )z?Crawlee-specific limit on the number of retries of the request.)rJ   r8   ri   s   &r4   r8   Request.max_retries  r   r3   c                   V ^8  d   QhRR/# r   r$   )rQ   s   "r4   rR   r     s     8 8
 8r3   c                .    V P                   P                  # )zFCrawlee-specific number of finished session rotations for the request.rJ   r;   ri   s   &r4   r;   Request.session_rotation_count  s       777r3   c                    V ^8  d   QhRRRR/# )rM   new_session_rotation_countrn   rP   r]   r$   )rQ   s   "r4   rR   r     s     N N N Nr3   c                	&    WP                   n        R # rU   r   )rX   r   s   &&r4   r;   r     s    3M0r3   c                   V ^8  d   QhRR/# )rM   rP   r   r$   )rQ   s   "r4   rR   r     s     ; ;/ ;r3   c                B    V P                   P                  ;'       g    R# )z5The strategy that was used for enqueuing the request.allrJ   r9   ri   s   &r4   r9   Request.enqueue_strategy  s       11::U:r3   c                    V ^8  d   QhRRRR/# )rM   new_enqueue_strategyr   rP   r]   r$   )rQ   s   "r4   rR   r     s     B B_ B Br3   c                	&    WP                   n        R # rU   r   )rX   r   s   &&r4   r9   r     s    -A*r3   c                   V ^8  d   QhRR/# r   r$   )rQ   s   "r4   rR   r     s     1 1 1r3   c                .    V P                   P                  # )z0The last proxy tier used to process the request.rJ   r=   ri   s   &r4   r=   Request.last_proxy_tier  s       000r3   c                    V ^8  d   QhRRRR/# r   r$   )rQ   s   "r4   rR   r     s     6 6 6 6r3   c                	&    WP                   n        R # rU   r   r   s   &&r4   r=   r     s    ,5)r3   c                   V ^8  d   QhRR/# rM   rP   rv   r$   )rQ   s   "r4   rR   r     s     + +4 +r3   c                .    V P                   P                  # )zJIndicate whether the request should be enqueued at the front of the queue.rJ   r>   ri   s   &r4   r>   Request.forefront  s       ***r3   c                    V ^8  d   QhRRRR/# )rM   r   rv   rP   r]   r$   )rQ   s   "r4   rR   r     s     0 04 0D 0r3   c                	&    WP                   n        R # rU   r   r   s   &&r4   r>   r     s    &/#r3   c                   V ^8  d   QhRR/# r   r$   )rQ   s   "r4   rR   r     s     + +T +r3   c                    V P                   RJ# )z*Indicates whether the request was handled.N)r   ri   s   &r4   was_already_handledRequest.was_already_handled  s     d**r3   r$   )#r%   r&   r'   r(   r)   r   r   rB   r   r   r   r   r   r   r   r   r   r   classmethodr   r   propertyrK   rA   rJ   r?   setterr:   r8   r;   r9   r=   r>   r   r2   )__conditional_annotations__s   @r4   r   r      s    . ttLLEE	 
PO 9>F5= 	      *},#13	.3	
 LK#
 	
	 >?K:>78=H5=OfjJcjjGKJDK1c #	c
 8<c -1c !c "&c "&c #(c ).c  %c 48c #'c cJ0D 0
 6 6 , , & & - - 2 2 ' ' \\, , - - 8 8 ""N #N ; ; B B 1 1 6 6 + + 0 0 + +r3   r   c                  &    ] tR tRt$ RtR]R&   RtR# )RequestWithLocki  z0A crawling request with information about locks.z1Annotated[datetime, Field(alias='lockExpiresAt')]lock_expires_atr$   Nr   r$   r3   r4   r   r     s    :FF.r3   r   N)2
__future__r   collections.abcr   r   r   enumr   typingr   r	   r
   r   r   pydanticr   r   r   r   r   r   r   yarlr   crawlee._typesr   r   r   r   r   crawlee._utils.cryptor   crawlee._utils.docsr   crawlee._utils.requestsr   crawlee._utils.urlsr   typing_extensionsr   r   r    r"   r6   rO   rD   user_data_adapterr   r   r   r$   r3   r4   <module>r     s    " 4   A A p p p  b b 9 * 6 1==
7 
9 9>11y..>)>? 11h  )  G)Y ) ). N]+i ]+ ]+@	/g /r3   