+
    Vi                    z  a  Rd tL0 t R t^ RIt^ RIt^ RIt^ RIHtHtHtH	t	H
t
HtHtHtHt ^ RIt^ RIHt ^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIHt R t]! 4       t]P6                  ! R4      t] ^ k ]! R4      t ! R R	]P<                  4      t ! R
 R]P<                  4      t  ! R R]P<                  4      t! ! R R]P<                  4      t" ! R R]P<                  ]],          4      t# ! R R]P<                  4      t$ ! R R]P<                  4      t% ! R R]P<                  4      t& ! R R]P<                  4      t' ! R R]P<                  4      t( ! R R]P<                  4      t) ! R R]P<                  4      t* ! R  R!]P<                  4      t+ ! R" R#]P<                  4      t, ! R$ R%]P<                  4      t- ! R& R']P<                  4      t. ! R( R)]P<                  4      t/ ! R* R+]P<                  4      t0 ! R, R-]P<                  4      t1 ! R. R/]P<                  4      t2 ! R0 R1]'4      t3 ! R2 R3]#],          ]],          4      t4 ! R4 R5]P<                  4      t5 ! R6 R7]P<                  4      t6 ! R8 R9]P<                  4      t7 ! R: R;]P<                  4      t8 ! R< R=]P<                  4      t9 ! R> R?]P<                  4      t: ! R@ RA]P<                  4      t; ! RB RC]P<                  4      t< ! RD RE]P<                  4      t= ! RF RG]P<                  ]],          4      t> ! RH RI]P<                  4      t? ! RJ RK]P<                  4      t@ ! RL RM]P<                  4      tA ! RN RO]P<                  4      tB ! RP RQ]P<                  4      tC ! RR RS]P<                  4      tD ! RT RU]P<                  4      tE ! RV RW]P<                  4      tF ! RX RY]P<                  4      tG ! RZ RK]P<                  4      t@ ! R[ RE]P<                  4      t= ! R\ R]4      tH ! R^ R_4      tI ! R` Ra]H4      tJ ! Rb Rc]I4      tKR# )ea  
FirecrawlApp Module

This module provides a class `FirecrawlApp` for interacting with the Firecrawl API.
It includes methods to scrape URLs, perform searches, initiate and monitor crawl jobs,
and check the status of these jobs. The module uses requests for HTTP communication
and handles retries for certain HTTP status codes.

Classes:
    - FirecrawlApp: Main class for interacting with the Firecrawl API.
N)	AnyDictOptionalListUnionCallableLiteralTypeVarGeneric)datetime)Fieldc                      ^ RI Hp  \        P                  P	                  \
        4      pV ! \        P                  P                  VR4      4      P                  4       p\        P                  ! RV\        P                  4      pV'       d    VP                  ^4      P                  4       # R#   \         d    \        R4        R# i ; i)    )Pathz__init__.pyz"^__version__ = ['\"]([^'\"]*)['\"]z&Failed to get version from __init__.pyN)pathlibr   ospathdirname__file__join	read_textresearchMgroupstrip	Exceptionprint)r   package_pathversion_fileversion_matchs       Y/home/ubuntu/hermes-agent/venv/lib/python3.14/site-packages/firecrawl/firecrawl.backup.pyget_versionr"      s    	WW__X.l"'',,|]CDNNPlii E|UWUYUYZm	$$Q'--/
/ 
	 45s   B
B. B. .CC	firecrawlTc                   8   a  ] tR t^Qt o RtRtRtV 3R ltRtV t	R# )AgentOptionszConfiguration for the agent.FIRE-1Nc                P   < V ^8  d   Qh/ S[ R,          ;R&   S[S[,          ;R&   # )   r'   modelpromptr   r   str)format__classdict__s   "r!   __annotate__AgentOptions.__annotate__Q   s&     8'  SM       )
__name__
__module____qualname____firstlineno____doc__r*   r+   __annotate_func____static_attributes____classdictcell__r/   s   @r!   r&   r&   Q   s     &'E F  r2   r&   c                   4   a  ] tR t^Vt o RtRtV 3R ltRtV tR# )AgentOptionsExtract2Configuration for the agent in extract operations.r'   c                4   < V ^8  d   Qh/ S[ R,          ;R&   # r)   r'   r*   r   )r.   r/   s   "r!   r0    AgentOptionsExtract.__annotate__V        8' r2   r3   N	r4   r5   r6   r7   r8   r*   r9   r:   r;   r<   s   @r!   r>   r>   V        <'E  r2   r>   c                   0   a  ] tR t^Zt o RtV 3R ltRtV tR# )ActionsResultz,Result of actions performed during scraping.c                R   < V ^8  d   Qh/ S[ S[,          ;R&   S[ S[,          ;R&   # )r)   screenshotspdfs)r   r-   )r.   r/   s   "r!   r0   ActionsResult.__annotate__Z   s$     c  s)O r2   r3   Nr4   r5   r6   r7   r8   r9   r:   r;   r<   s   @r!   rH   rH   Z   s     6  r2   rH   c                   `   a  ] tR t^_t o RtRtRt]P                  ! RRR7      t	V 3R lt
RtV tR# )ChangeTrackingDataz&
Data for the change tracking format.
Njsonaliasc                   < V ^8  d   Qh/ S[ S[,          ;R&   S[;R&   S[;R&   S[ S[S[S[3,          ,          ;R&   S[ S[,          ;R&   # )r)   previousScrapeAtchangeStatus
visibilitydiff
json_field)r   r-   r   r   )r.   r/   s   "r!   r0   ChangeTrackingData.__annotate___   sZ      sm*	 
   O  4S>
")  B r2   r3   )r4   r5   r6   r7   r8   rT   rW   pydanticr   rX   r9   r:   r;   r<   s   @r!   rO   rO   _   s0      '+ &*D (t6 BJ  r2   rO   c                      a  ] tR t^it o RtRtRtRtRtRt	Rt
]P                  ! RRR7      tRtRtRtRtRtRtV 3R ltRtV tR# )FirecrawlDocumentz-Document retrieved or processed by Firecrawl.NrP   rQ   c                  < V ^8  d   Qh/ S[ S[,          ;R&   S[ S[,          ;R&   S[ S[,          ;R&   S[ S[,          ;R&   S[ S[S[,          ,          ;R&   S[ S[,          ;R&   S[ S[,          ;R&   S[ S[,          ;R&   S[ S[,          ;R	&   S[ S[,          ;R
&   S[ S[,          ;R&   S[ S[,          ;R&   S[ S[,          ;R&   # )r)   urlmarkdownhtmlrawHtmllinksextractrX   
screenshotmetadataactionstitledescriptionchangeTracking)r   r-   r   r$   r   rH   rO   )r.   r/   s   "r!   r0   FirecrawlDocument.__annotate__i   s     	#  sm"  3-	 
 c]!  DI%  a[  @  $  sm"  m$+  C=  #%  /07 r2   r3   )r4   r5   r6   r7   r8   r^   r_   r`   ra   rb   rc   rZ   r   rX   rd   re   rf   rg   rh   ri   r9   r:   r;   r<   s   @r!   r\   r\   i   s[     7C"HD!G!%EG&nnT@J $J"H'+GE!%K37N  r2   r\   c                   8   a  ] tR t^yt o RtRtRtV 3R ltRtV t	R# )LocationConfigz$Location configuration for scraping.Nc                b   < V ^8  d   Qh/ S[ S[,          ;R&   S[ S[S[,          ,          ;R&   # )r)   country	languages)r   r-   r   )r.   r/   s   "r!   r0   LocationConfig.__annotate__y   s*     c]!  S	") r2   r3   )
r4   r5   r6   r7   r8   rn   ro   r9   r:   r;   r<   s   @r!   rl   rl   y   s     .!G%)I  r2   rl   c                   <   a  ] tR t^~t o RtRtRtRtV 3R ltRt	V t
R# )WebhookConfigzConfiguration for webhooks.Nc                   < V ^8  d   Qh/ S[ ;R&   S[S[S[ S[ 3,          ,          ;R&   S[S[S[ S[ 3,          ,          ;R&   S[S[S[R,          ,          ,          ;R&   # )r)   r^   headersre   events)	completedfailedpagestarted)r-   r   r   r   r   )r.   r/   s   "r!   r0   WebhookConfig.__annotate__~   s`     	H  d38n%,  tCH~&-	 
 T'"JKLMT r2   r3   )r4   r5   r6   r7   r8   rt   re   ru   r9   r:   r;   r<   s   @r!   rr   rr   ~   s     %(,G)-HPTF  r2   rr   c                   d   a  ] tR t^t o RtRt]P                  ! RRR7      tRt	Rt
V 3R ltRtV tR# )ChangeTrackingOptionsz"Configuration for change tracking.NschemarQ   c                   < V ^8  d   Qh/ S[ S[S[R,          ,          ,          ;R&   S[ S[,          ;R&   S[ S[,          ;R&   S[ S[,          ;R&   # )r)   modesschema_fieldr+   tag)zgit-diffrP   )r   r   r   r   r-   )r.   r/   s   "r!   r0   "ChangeTrackingOptions.__annotate__   sS     D!3456=  3-F  SM 	 
 
# r2   r3   )r4   r5   r6   r7   r8   r   rZ   r   r   r+   r   r9   r:   r;   r<   s   @r!   r|   r|      s.     ,9=E"*..X"FL FC  r2   r|   c                   t   a  ] tR t^t o RtRtRtRtRtRt	Rt
RtRtRtRtRtRtRtRtRtRtRtV 3R ltRtV tR# )ScrapeOptions#Parameters for scraping operations.N0u  c                X  < V ^8  d   Qh/ S[ S[S[R,          ,          ,          ;R&   S[ S[S[S[3,          ,          ;R&   S[ S[S[,          ,          ;R&   S[ S[S[,          ,          ;R&   S[ S[,          ;R&   S[ S[,          ;R&   S[ S[,          ;R&   S[ S[,          ;R&   S[ S[,          ;R	&   S[ S[,          ;R
&   S[ S[,          ;R&   S[ S[,          ;R&   S[ S[R,          ,          ;R&   S[ S[,          ;R&   S[ S[,          ;R&   S[ S[,          ;R&   S[ S[,          ;R&   # )r)   formatsrt   includeTagsexcludeTagsonlyMainContentwaitFortimeoutlocationmobileskipTlsVerificationremoveBase64ImagesblockAdsproxychangeTrackingOptionsmaxAgestoreInCacheparsePDF
r_   r`   ra   contentrb   rd   screenshot@fullPagerc   rP   ri   basicstealthauto)	r   r   r   r   r-   boolintrl   r|   )r.   r/   s   "r!   r0   ScrapeOptions.__annotate__   s\    d7  $_  `  a  b  i  d38n%,  $s)$+	 
 $s)$+  d^*  c]!  c]"  ~&-  TN!  "$.  !-  tn#  G678?  $$9:A   SM ! " 4.'# $ tn#% r2   r3   )r4   r5   r6   r7   r8   r   rt   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r9   r:   r;   r<   s   @r!   r   r      sk     - eiG(,G'+K'+K&*O!G"G)-H!F*.)-#H;?E=A F#'L#H%  r2   r   c                   8   a  ] tR t^t o RtRtRtV 3R ltRtV t	R# )
WaitActionz'Wait action to perform during scraping.Nc                l   < V ^8  d   Qh/ S[ R,          ;R&   S[S[,          ;R&   S[S[,          ;R&   # )r)   waittypemillisecondsselector)r   r   r   r-   )r.   r/   s   "r!   r0   WaitAction.__annotate__   s6     
&/  3-&  sm"	 r2   r3   )
r4   r5   r6   r7   r8   r   r   r9   r:   r;   r<   s   @r!   r   r      s     1"&L"H	  r2   r   c                   8   a  ] tR t^t o RtRtRtV 3R ltRtV t	R# )ScreenshotActionz-Screenshot action to perform during scraping.Nc                l   < V ^8  d   Qh/ S[ R,          ;R&   S[S[,          ;R&   S[S[,          ;R&   # )r)   rd   r   fullPagequality)r   r   r   r   )r.   r/   s   "r!   r0   ScreenshotAction.__annotate__   s7     
,
  tn#  c]!	 r2   r3   )
r4   r5   r6   r7   r8   r   r   r9   r:   r;   r<   s   @r!   r   r      s     7#H!G	  r2   r   c                   0   a  ] tR t^t o RtV 3R ltRtV tR# )ClickActionz(Click action to perform during scraping.c                @   < V ^8  d   Qh/ S[ R,          ;R&   S[;R&   # )r)   clickr   r   r   r-   )r.   r/   s   "r!   r0   ClickAction.__annotate__   s!     
'
  M r2   r3   NrM   r<   s   @r!   r   r           2  r2   r   c                   0   a  ] tR t^t o RtV 3R ltRtV tR# )WriteActionz(Write action to perform during scraping.c                @   < V ^8  d   Qh/ S[ R,          ;R&   S[;R&   # )r)   writer   textr   )r.   r/   s   "r!   r0   WriteAction.__annotate__   s!     
'
  I r2   r3   NrM   r<   s   @r!   r   r      r   r2   r   c                   0   a  ] tR t^t o RtV 3R ltRtV tR# )PressActionz(Press action to perform during scraping.c                @   < V ^8  d   Qh/ S[ R,          ;R&   S[;R&   # )r)   pressr   keyr   )r.   r/   s   "r!   r0   PressAction.__annotate__   s!     
'
  
H r2   r3   NrM   r<   s   @r!   r   r      r   r2   r   c                   4   a  ] tR t^t o RtRtV 3R ltRtV tR# )ScrollActionz)Scroll action to perform during scraping.Nc                j   < V ^8  d   Qh/ S[ R,          ;R&   S[ R,          ;R&   S[S[,          ;R&   # )r)   scrollr   	directionr   )updownr,   )r.   r/   s   "r!   r0   ScrollAction.__annotate__   s8     
(
  |$$  sm"	 r2   r3   )	r4   r5   r6   r7   r8   r   r9   r:   r;   r<   s   @r!   r   r      s     3 #H	  r2   r   c                   0   a  ] tR t^t o RtV 3R ltRtV tR# )ScrapeActionz)Scrape action to perform during scraping.c                4   < V ^8  d   Qh/ S[ R,          ;R&   # )r)   scraper   rB   )r.   r/   s   "r!   r0   ScrapeAction.__annotate__   s     
(
 r2   r3   NrM   r<   s   @r!   r   r      s     3  r2   r   c                   0   a  ] tR t^t o RtV 3R ltRtV tR# )ExecuteJavascriptActionz5Execute javascript action to perform during scraping.c                @   < V ^8  d   Qh/ S[ R,          ;R&   S[;R&   # )r)   executeJavascriptr   scriptr   )r.   r/   s   "r!   r0   $ExecuteJavascriptAction.__annotate__   s"     
%
&&  K r2   r3   NrM   r<   s   @r!   r   r      s     ?  r2   r   c                   <   a  ] tR t^t o RtRtRtRtV 3R ltRt	V t
R# )	PDFActionz&PDF action to perform during scraping.Nc                   < V ^8  d   Qh/ S[ R,          ;R&   S[S[ R,          ,          ;R&   S[S[,          ;R&   S[S[,          ;R&   # )r)   pdfr   r.   	landscapescale)A0A1A2A3A4A5A6LetterLegalTabloidLedger)r   r   r   float)r.   r/   s   "r!   r0   PDFAction.__annotate__   sN     
%.  Wmnov  ~$	 
 E?! r2   r3   )r4   r5   r6   r7   r8   r.   r   r   r9   r:   r;   r<   s   @r!   r   r      s     0rvF $I!E  r2   r   c                   4   a  ] tR t^t o RtRtV 3R ltRtV tR# )ExtractAgentr?   r'   c                4   < V ^8  d   Qh/ S[ R,          ;R&   # rA   rB   )r.   r/   s   "r!   r0   ExtractAgent.__annotate__   rD   r2   r3   NrE   r<   s   @r!   r   r      rF   r2   r   c                   d   a  ] tR t^t o RtRt]P                  ! RRR7      tRt	Rt
V 3R ltRtV tR# )
JsonConfigzConfiguration for extraction.Nr}   rQ   c                   < V ^8  d   Qh/ S[ S[,          ;R&   S[ S[,          ;R&   S[ S[,          ;R&   S[ S[,          ;R&   # )r)   r+   r   systemPromptagent)r   r-   r   r   )r.   r/   s   "r!   r0   JsonConfig.__annotate__   sH     SM   3-F  3-&	 
 L!( r2   r3   )r4   r5   r6   r7   r8   r+   rZ   r   r   r   r   r9   r:   r;   r<   s   @r!   r   r      s.     ' F"*..X"FL"&L$(E  r2   r   c                   D   a  ] tR t^t o RtRtRtRtRtRt	V 3R lt
RtV tR# )ScrapeParamsr   Nc                   < V ^8  d   Qh/ S[ S[,          ;R&   S[ S[,          ;R&   S[ S[S[S[S[S[S[S[S[	S[
S[S[3	,          ,          ,          ;R&   S[ S[,          ;R&   S[ S[,          ;R&   # )r)   rc   jsonOptionsrf   r   webhook)r   r   r   r   r   r   r   r   r   r   r   r   r   r&   rr   )r.   r/   s   "r!   r0   ScrapeParams.__annotate__   s     j!(  *%,  d5-={KYdfr  uA  CZ  \e  "e  f  g  h  o	 
 L!(  m$+ r2   r3   )r4   r5   r6   r7   r8   rc   r   rf   r   r   r9   r:   r;   r<   s   @r!   r   r      s,     -$(G(,K koG$(E'+G  r2   r   c                   <   a  ] tR t^t o RtRtRtRtV 3R ltRt	V t
R# )ScrapeResponsez"Response from scraping operations.TNc                ^   < V ^8  d   Qh/ S[ ;R&   S[S[,          ;R&   S[S[,          ;R&   # )r)   successwarningerror)r   r   r-   )r.   r/   s   "r!   r0   ScrapeResponse.__annotate__   s2       c]!  C=	 r2   r3   r4   r5   r6   r7   r8   r   r   r   r9   r:   r;   r<   s   @r!   r   r      s     ,G!GE	  r2   r   c                   D   a  ] tR t^t o RtRtRtRtRtRt	V 3R lt
RtV tR# )BatchScrapeResponsez&Response from batch scrape operations.NTc                   < V ^8  d   Qh/ S[ S[,          ;R&   S[ S[,          ;R&   S[;R&   S[ S[,          ;R&   S[ S[S[,          ,          ;R&   # )r)   idr^   r   r   invalidURLs)r   r-   r   r   )r.   r/   s   "r!   r0    BatchScrapeResponse.__annotate__   sY       
#  	 
 C=  $s)$+ r2   r3   )r4   r5   r6   r7   r8   r  r^   r   r   r  r9   r:   r;   r<   s   @r!   r  r     s(     0BCGE'+K  r2   r  c                   8   a  ] tR t^t o RtRtRtV 3R ltRtV t	R# )BatchScrapeStatusResponsez)Response from batch scrape status checks.TNc                   < V ^8  d   Qh/ S[ ;R&   S[R	,          ;R&   S[;R&   S[;R&   S[;R&   S[;R&   S[S[,          ;R&   S[S[,          ;R&   # 
r)   r   rv   statustotalcreditsUsed	expiresAtnextdata)scrapingrv   rw   	cancelledr   r   r   r   r   r-   r   r\   )r.   r/   s   "r!   r0   &BatchScrapeStatusResponse.__annotate__   y       BCC  N	 
 J      3-   
!! r2   r3   
r4   r5   r6   r7   r8   r   r  r9   r:   r;   r<   s   @r!   r  r     s     3G D  r2   r  c                   t   a  ] tR t^t o RtRtRtRtRtRt	Rt
RtRtRtRtRtRtRtRtRtRtRtV 3R ltRtV tR# )CrawlParamsz#Parameters for crawling operations.Nc                ,  < V ^8  d   Qh/ S[ S[S[,          ,          ;R&   S[ S[S[,          ,          ;R&   S[ S[,          ;R&   S[ S[,          ;R&   S[ S[,          ;R&   S[ S[,          ;R&   S[ S[,          ;R&   S[ S[,          ;R&   S[ S[,          ;R	&   S[ S[,          ;R
&   S[ S[S[S[3,          ,          ;R&   S[ S[,          ;R&   S[ S[,          ;R&   S[ S[,          ;R&   S[ S[,          ;R&   S[ S[,          ;R&   S[ S[,          ;R&   # )r)   includePathsexcludePathsmaxDepthmaxDiscoveryDepthlimitallowBackwardLinkscrawlEntireDomainallowExternalLinksignoreSitemapscrapeOptionsr   deduplicateSimilarURLsignoreQueryParametersregexOnFullURLdelaymaxConcurrencyallowSubdomains)r   r   r-   r   r   r   r   rr   )r.   r/   s   "r!   r0   CrawlParams.__annotate__   s:    49%,  49%,  sm"	 
  }+  C=  !-   ~,  !-  D>(  M*1  eC./07  %TN1  $D>0  TN)   C=! " SM(# $ d^*% r2   r3   )r4   r5   r6   r7   r8   r  r  r  r  r  r  r   r!  r"  r#  r   r$  r%  r&  r'  r(  r)  r9   r:   r;   r<   s   @r!   r  r     sj     -(,L(,L"H'+E)-(,)-$(M-1M37G-1,0%)NE$(N&*O%  r2   r  c                   @   a  ] tR tRt o RtRtRtRtRtV 3R lt	Rt
V tR# )CrawlResponsei  z"Response from crawling operations.NTc                z   < V ^8  d   Qh/ S[ S[,          ;R&   S[ S[,          ;R&   S[;R&   S[ S[,          ;R&   # )r)   r  r^   r   r   )r   r-   r   )r.   r/   s   "r!   r0   CrawlResponse.__annotate__  sC       
#  	 
 C= r2   r3   )r4   r5   r6   r7   r8   r  r^   r   r   r9   r:   r;   r<   s   @r!   r,  r,    s#     ,BCGE  r2   r,  c                   8   a  ] tR tRt o RtRtRtV 3R ltRtV t	R# )CrawlStatusResponsei  z"Response from crawl status checks.TNc                   < V ^8  d   Qh/ S[ ;R&   S[R	,          ;R&   S[;R&   S[;R&   S[;R&   S[;R&   S[S[,          ;R&   S[S[,          ;R&   # r
  r  )r.   r/   s   "r!   r0    CrawlStatusResponse.__annotate__  r  r2   r3   r  r<   s   @r!   r0  r0    s     ,G D  r2   r0  c                   0   a  ] tR tRt o RtV 3R ltRtV tR# )CrawlErrorsResponsei#  z2Response from crawl/batch scrape error monitoring.c                h   < V ^8  d   Qh/ S[ S[S[S[3,          ,          ;R&   S[ S[,          ;R&   # )r)   errorsrobotsBlocked)r   r   r-   )r.   r/   s   "r!   r0    CrawlErrorsResponse.__annotate__#  s.     c3h    9 r2   r3   NrM   r<   s   @r!   r4  r4  #  s     <  r2   r4  c                   L   a  ] tR tRt o RtRtRtRtRtRt	Rt
RtV 3R ltRtV tR# )	MapParamsi(  z"Parameters for mapping operations.Nr   c                   < V ^8  d   Qh/ S[ S[,          ;R&   S[ S[,          ;R&   S[ S[,          ;R&   S[ S[,          ;R&   S[ S[,          ;R&   S[ S[,          ;R&   S[ S[,          ;R&   # )r)   r   r"  includeSubdomainssitemapOnlyr  r   useIndex)r   r-   r   r   )r.   r/   s   "r!   r0   MapParams.__annotate__(  sz     SM   D>(   ~,	 
 $&  C=  c]"  tn# r2   r3   )r4   r5   r6   r7   r8   r   r"  r<  r=  r  r   r>  r9   r:   r;   r<   s   @r!   r:  r:  (  s3     , F$(M(,"&KE"G#H  r2   r:  c                   <   a  ] tR tRt o RtRtRtRtV 3R ltRt	V t
R# )MapResponsei2  z!Response from mapping operations.TNc                n   < V ^8  d   Qh/ S[ ;R&   S[S[S[,          ,          ;R&   S[S[,          ;R&   # )r)   r   rb   r   )r   r   r   r-   )r.   r/   s   "r!   r0   MapResponse.__annotate__2  s7       DI%  C=	 r2   r3   )r4   r5   r6   r7   r8   r   rb   r   r9   r:   r;   r<   s   @r!   rA  rA  2  s     +G!%EE	  r2   rA  c                   x   a  ] tR tRt o RtRt]P                  ! RRR7      tRt	Rt
RtRtRtRtRtV 3R ltRtV tR# )ExtractParamsi8  z0Parameters for extracting information from URLs.Nr}   rQ   c                  < V ^8  d   Qh/ S[ S[,          ;R&   S[ S[,          ;R&   S[ S[,          ;R&   S[ S[,          ;R&   S[ S[,          ;R&   S[ S[,          ;R&   S[ S[,          ;R&   S[ S[,          ;R&   S[ S[,          ;R	&   # )
r)   r+   r   r   r!  enableWebSearchr<  originshowSourcesr#  )r   r-   r   r   r   )r.   r/   s   "r!   r0   ExtractParams.__annotate__8  s     SM   3-F  3-&	 
 !-  d^*   ~,  SM   $&  M*1 r2   r3   )r4   r5   r6   r7   r8   r+   rZ   r   r   r   r!  rG  r<  rH  rI  r#  r9   r:   r;   r<   s   @r!   rE  rE  8  sI     : F"*..X"FL"&L)-&*O(, F"&K-1M  r2   rE  c                   P   a  ] tR tRt o RtRtRtRtRtRt	Rt
RtRtV 3R ltRtV tR# )ExtractResponseiD  z!Response from extract operations.NTc                  < V ^8  d   Qh/ S[ S[,          ;R&   S[ S[R	,          ,          ;R&   S[ S[,          ;R&   S[;R&   S[ S[,          ;R&   S[ S[,          ;R&   S[ S[,          ;R&   S[ S[S[S[3,          ,          ;R&   # )
r)   r  r  r  r   r  r   r   sources
processingrv   rw   )r   r-   r   r   r   r$   r   r   )r.   r/   s   "r!   r0   ExtractResponse.__annotate__D  s       W@ABI  !(	 
   1+  C=  c]!  d38n%, r2   r3   )r4   r5   r6   r7   r8   r  r  r  r   r  r   r   rN  r9   r:   r;   r<   s   @r!   rL  rL  D  s7     +BEIF$(IGDE!G(,G  r2   rL  c                   P   a  ] tR tRt o ^tRtRtRtRtRt	Rt
RtRtV 3R ltRtV tR# )	SearchParamsiO  Nenusapii`  c                "  < V ^8  d   Qh/ S[ ;R&   S[S[,          ;R&   S[S[ ,          ;R&   S[S[ ,          ;R&   S[S[ ,          ;R&   S[S[ ,          ;R&   S[S[ ,          ;R&   S[S[ ,          ;R&   S[S[,          ;R	&   S[S[,          ;R
&   # )r)   queryr  tbsfilterlangrn   r   rH  r   r#  )r-   r   r   r   )r.   r/   s   "r!   r0   SearchParams.__annotate__O  s     J C=  
#  SM 	 
 3-  c]!  sm"  SM!  c]"  M*1 r2   r3   )r4   r5   r6   r7   r  rY  rZ  r[  rn   r   rH  r   r#  r9   r:   r;   r<   s   @r!   rS  rS  O  s9     EC FD!G"H!F"G-1M  r2   rS  c                   <   a  ] tR tRt o RtRtRtRtV 3R ltRt	V t
R# )SearchResponsei[  z Response from search operations.TNc                z   < V ^8  d   Qh/ S[ ;R&   S[S[,          ;R&   S[S[,          ;R&   S[S[,          ;R&   # r)   r   r  r   r   )r   r   r\   r   r-   )r.   r/   s   "r!   r0   SearchResponse.__annotate__[  sE        
!!  c]!	 
 C= r2   r3   r   r<   s   @r!   r^  r^  [  s     *G!GE  r2   r^  c                   @   a  ] tR tRt o Rt^
tRtRtRtV 3R lt	Rt
V tR# )GenerateLLMsTextParamsib  z3
Parameters for the LLMs.txt generation operation.
FTNc                   < V ^8  d   Qh/ S[ S[,          ;R&   S[ S[,          ;R&   S[ S[,          ;R&   S[ S[,          ;R&   # )r)   maxUrlsshowFullTextcache,_GenerateLLMsTextParams__experimental_stream)r   r   r   )r.   r/   s   "r!   r0   #GenerateLLMsTextParams.__annotate__b  sI      c]	 
 4.(  D>   $D>0 r2   r3   )r4   r5   r6   r7   r8   re  rf  rg  rh  r9   r:   r;   r<   s   @r!   rc  rc  b  s(       G#(L E,0  r2   rc  c                   H   a  ] tR tRt o Rt^tRt^tRtRt	Rt
V 3R ltRtV tR# )DeepResearchParamsik  z-
Parameters for the deep research operation.
i  Nc                   < V ^8  d   Qh/ S[ S[,          ;R&   S[ S[,          ;R&   S[ S[,          ;R&   S[ S[,          ;R&   S[ S[,          ;R&   S[ S[,          ;R&   # )r)   r  	timeLimitre  analysisPromptr   -_DeepResearchParams__experimental_streamSteps)r   r   r-   r   )r.   r/   s   "r!   r0   DeepResearchParams.__annotate__k  sk      sm	 
 }"  c]  SM(  3-&  !)5 r2   r3   )r4   r5   r6   r7   r8   r  rm  re  rn  r   ro  r9   r:   r;   r<   s   @r!   rk  rk  k  s2       H"IG$(N"&L15  r2   rk  c                   4   a  ] tR tRt o RtRtV 3R ltRtV tR# )DeepResearchResponseiv  z,
Response from the deep research operation.
Nc                N   < V ^8  d   Qh/ S[ ;R&   S[;R&   S[S[,          ;R&   # r)   r   r  r   r   r-   r   )r.   r/   s   "r!   r0   !DeepResearchResponse.__annotate__v  s.      M	 
 	G  C= r2   r3   )	r4   r5   r6   r7   r8   r   r9   r:   r;   r<   s   @r!   rr  rr  v  s     
  E  r2   rr  c                   8   a  ] tR tRt o RtRtRtV 3R ltRtV t	R# )DeepResearchStatusResponsei~  z3
Status response from the deep research operation.
Nc                $  < V ^8  d   Qh/ S[ ;R&   S[S[S[S[3,          ,          ;R&   S[;R&   S[S[,          ;R&   S[;R&   S[;R&   S[;R&   S[S[S[S[3,          ,          ;R&   S[S[S[S[3,          ,          ;R	&   S[S[,          ;R
&   # )r)   r   r  r  r   r  currentDepthr  
activitiesrN  	summaries)r   r   r   r-   r   r   r   )r.   r/   s   "r!   r0   'DeepResearchStatusResponse.__annotate__~  s      M	 
 4S>
")  K  C=  N    M  T#s(^$$  $sCx.!!  Cy r2   r3   )
r4   r5   r6   r7   r8   r  r   r9   r:   r;   r<   s   @r!   rx  rx  ~  s      &*DE  r2   rx  c                   8   a  ] tR tRt o RtRtRtV 3R ltRtV t	R# )GenerateLLMsTextResponsei  z-Response from LLMs.txt generation operations.TNc                N   < V ^8  d   Qh/ S[ ;R&   S[;R&   S[S[,          ;R&   # rt  ru  )r.   r/   s   "r!   r0   %GenerateLLMsTextResponse.__annotate__  s-       	G  C=	 r2   r3   )
r4   r5   r6   r7   r8   r   r   r9   r:   r;   r<   s   @r!   r  r    s     7GE	  r2   r  c                   0   a  ] tR tRt o RtV 3R ltRtV tR# )"GenerateLLMsTextStatusResponseData  Nc                B   < V ^8  d   Qh/ S[ ;R&   S[S[ ,          ;R&   # )r)   llmstxtllmsfulltxt)r-   r   )r.   r/   s   "r!   r0   /GenerateLLMsTextStatusResponseData.__annotate__  s     L #% r2   r3   )r4   r5   r6   r7   r  r9   r:   r;   r<   s   @r!   r  r    s     !%K  r2   r  c                   <   a  ] tR tRt o RtRtRtRtV 3R ltRt	V t
R# )GenerateLLMsTextStatusResponsei  z4Status response from LLMs.txt generation operations.TNc                   < V ^8  d   Qh/ S[ ;R&   S[S[,          ;R&   S[R,          ;R&   S[S[,          ;R&   S[;R&   # )r)   r   r  r  r   r  rO  )r   r   r  r   r-   )r.   r/   s   "r!   r0   +GenerateLLMsTextStatusResponse.__annotate__  sS       5
6=  788	 
 C=  N r2   r3   )r4   r5   r6   r7   r8   r   r  r   r9   r:   r;   r<   s   @r!   r  r    s     >G9=DE  r2   r  c                   8   a  ] tR tRt o RtRtRtV 3R ltRtV t	R# )r^  i  z%
Response from the search operation.
Nc                   < V ^8  d   Qh/ S[ ;R&   S[S[S[S[3,          ,          ;R&   S[S[,          ;R&   S[S[,          ;R&   # r`  )r   r   r   r-   r   r   )r.   r/   s   "r!   r0   ra    sM      M	 
 tCH~
  c]!  C= r2   r3   )
r4   r5   r6   r7   r8   r   r   r9   r:   r;   r<   s   @r!   r^  r^    s     
 "GE  r2   c                   t   a  ] tR tRt o RtRt]P                  ! RRR7      tRt	Rt
RtRtRtRtV 3R ltRtV tR# )	rE  i  z'
Parameters for the extract operation.
Nr}   rQ   Fc                  < V ^8  d   Qh/ S[ S[,          ;R&   S[ S[,          ;R&   S[ S[,          ;R&   S[ S[,          ;R&   S[ S[,          ;R&   S[ S[,          ;R&   S[ S[,          ;R&   S[ S[S[S[3,          ,          ;R&   # )	r)   r+   r   system_promptallow_external_linksenable_web_searchrG  show_sourcesr   )r   r-   r   r   r   )r.   r/   s   "r!   r0   rJ    s      SM 	 
 3-F  C='  #4.0   ~-  d^+  4.(  DcN#* r2   r3   )r4   r5   r6   r7   r8   r+   rZ   r   r   r  r  r  rG  r  r   r9   r:   r;   r<   s   @r!   rE  rE    sH      !F"*..X"FL#'M+0(-&+O#(L&*E  r2   c            ,         a  ] tR tRt o RV 3R lR ll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RRRRRRRRRRRRR/V 3R lR lltRRRRR RR!RR"RRRRRR#R/V 3R$ lR% ll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R0RR1RR2RR3RR4RRRR5^R6R/V 3R7 lR8 ll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R0RR1RR2RR3RR4RRRR6R/V 3R9 lR: lltV 3R; lR< lt	V 3R= lR> lt
V 3R? lR@ l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R0RR1RR2RR3RR4RRRR6R/V 3RA lRB lltRCRR-RRDRRERRRRRRFR/V 3RG lRH ll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RRRR5^R4RRRR6R/V 3RI lRJ ll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RRRR4RR6RRR/V 3RK lRL ll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RRRR4RRRR6R/V 3RM lRN lltV 3RO lRP ltV 3RQ lRR ltRRSRRTRRURR,RVRWRVRXRVRR/V 3RY lRZ llltV 3R[ lR\ ltRRSRRTRRURR,RVRWRVRXRVRR/V 3R] lR^ llltR_RR`RRaRRbR/V 3Rc lRd lltR_RR`RRaRRbR/V 3Re lRf lltV 3Rg lRh ltRV 3Ri lRj lltRV 3Rk lRl lltRV 3Rm lRn lltRV 3Ro lRp lltV 3Rq lRr ltV 3Rs lRt ltV 3Ru lRv ltR(RRwRR_RRxRRURRyRRzRR{R/V 3R| lR} llt R(RRwRR_RRxRRURRyR/V 3R~ lR llt!V 3R lR lt"V 3R lR lt#R t$Rt%V t&R# )FirecrawlAppi  Nc                J   < V ^8  d   QhRS[ S[,          RS[ S[,          RR/# )r)   api_keyapi_urlreturnN)r   r-   )r.   r/   s   "r!   r0   FirecrawlApp.__annotate__  s0     O O Ox} OX\ Or2   c                ^   T;'       g    \         P                  ! R4      V n        T;'       g    \         P                  ! RR4      V n        RV P                  9   d/   V P                  f!   \        P                  R4       \        R4      h\        P                  RV P                   24       R# )	z
Initialize the FirecrawlApp instance with API key, API URL.

Args:
    api_key (Optional[str]): API key for authenticating with the Firecrawl API.
    api_url (Optional[str]): Base URL for the Firecrawl API.
FIRECRAWL_API_KEYFIRECRAWL_API_URLzhttps://api.firecrawl.devzapi.firecrawl.devNz%No API key provided for cloud servicezNo API key providedz'Initialized FirecrawlApp with API URL: )r   getenvr  r  loggerr   
ValueErrordebug)selfr  r  s   &&&r!   __init__FirecrawlApp.__init__  s     @@")),?"@]]")),?A\"] $,,.4<<3GNNBC233>t||nMNr2   r   rt   include_tagsexclude_tagsonly_main_contentwait_forr   r   r   r   skip_tls_verificationremove_base64_images	block_adsr   	parse_pdfrc   json_optionsrf   change_tracking_optionsmax_agestore_in_cachezero_data_retentionr   c          1        < V ^8  d   QhRS[ RS[S[S[R,          ,          ,          RS[S[S[ S[ 3,          ,          RS[S[S[ ,          ,          RS[S[S[ ,          ,          RS[S[,          RS[S[,          R	S[S[,          R
S[S[,          RS[S[,          RS[S[,          RS[S[,          RS[S[,          RS[S[R,          ,          RS[S[,          RS[S[,          RS[S[,          RS[S[S[	S[
S[S[S[S[S[S[S[S[3	,          ,          ,          RS[S[,          RS[S[,          RS[S[,          RS[S[,          RS[S[,          RS[S[,          /# )r)   r^   r   rc   rt   r  r  r  r  r   r   r   r  r  r  r   r  r  rf   r  r  r  r  r   r  r   r   )r-   r   r   r   r   r   r   rl   r   r   r   r   r   r   r   r   r   r   r   r|   r&   r   r   )r.   r/   s   "r!   r0   r    s    Y7 Y7Y7 d7  ,g  $h  i  j	Y7
 d38n-Y7 #49-Y7 #49-Y7  (~Y7 smY7 c]Y7 ~.Y7 TNY7 $,D>Y7 #+4.Y7  ~Y7  G$>?@!Y7"  ~#Y7$ j)%Y7& #:.'Y7( d55E{T_alnz  }I  Kb  dm  *m  $n  o  p)Y7* &..C%D+Y7, c]-Y7. %TN/Y70 "*$1Y72 L)3Y74 (,5Y7r2   c               6   V P                  VR4       V P                  4       pRVRR\         2/pV'       d   VVR&   V'       d   VVR&   V'       d   VVR&   V'       d   VVR&   Ve   VVR
&   V'       d   VVR&   V'       d   VVR&   V	'       d   V	P                  RRR7      VR&   V
e   V
VR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   V'       d   VVR&   Ve   VVR&   Vex   V P	                  V4      p\        V\        4      '       d#   RV9   d   V P	                  VR,          4      VR&   \        V\        4      '       d   TMVP                  RRR7      VR&   Vex   V P	                  V4      p\        V\        4      '       d#   RV9   d   V P	                  VR,          4      VR&   \        V\        4      '       d   TMVP                  RRR7      VR&   V'       d?   V Uu. uF.  p\        V\        4      '       d   TMVP                  RRR7      NK0  	  upVR&   V'       d/   \        V\        4      '       d   TMVP                  RRR7      VR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   Ve   VP                  RRR7      VR&   VP                  V4       RV9   dG   VR,          '       d8   RVR,          9   d*   V P	                  VR,          R,          4      VR,          R&   RV9   dG   VR,          '       d8   RVR,          9   d*   V P	                  VR,          R,          4      VR,          R&   \        P                  ! V P                   R2TTVe   VR ,          ^,           MR	R!7      pVP                  ^8X  dl    VP                  4       pVP                  R"4      '       d   R#V9   d   \        R(/ VR#,          B # R$V9   d   \        R%VR$,           24      h\        R%V 24      hV P!                  VR'4       R	# u upi   \         d    \        R&4      hi ; i))a  
Scrape and extract content from a URL.

Args:
  url (str): Target URL to scrape
  formats (Optional[List[Literal["markdown", "html", "rawHtml", "content", "links", "screenshot", "screenshot@fullPage", "extract", "json"]]]): Content types to retrieve (markdown/html/etc)
  headers (Optional[Dict[str, str]]): Custom HTTP headers
  include_tags (Optional[List[str]]): HTML tags to include
  exclude_tags (Optional[List[str]]): HTML tags to exclude
  only_main_content (Optional[bool]): Extract main content only
  wait_for (Optional[int]): Wait for a specific element to appear
  timeout (Optional[int]): Request timeout (ms)
  location (Optional[LocationConfig]): Location configuration
  mobile (Optional[bool]): Use mobile user agent
  skip_tls_verification (Optional[bool]): Skip TLS verification
  remove_base64_images (Optional[bool]): Remove base64 images
  block_ads (Optional[bool]): Block ads
  proxy (Optional[Literal["basic", "stealth", "auto"]]): Proxy type (basic/stealth)
  extract (Optional[JsonConfig]): Content extraction settings
  json_options (Optional[JsonConfig]): JSON extraction settings
  actions (Optional[List[Union[WaitAction, ScreenshotAction, ClickAction, WriteAction, PressAction, ScrollAction, ScrapeAction, ExecuteJavascriptAction, PDFAction]]]): Actions to perform
  change_tracking_options (Optional[ChangeTrackingOptions]): Change tracking settings
  zero_data_retention (Optional[bool]): Whether to delete data after scrape is done
  agent (Optional[AgentOptions]): Agent configuration for FIRE-1 model


Returns:
  ScrapeResponse with:
  * Requested content formats
  * Page metadata
  * Extraction results
  * Success/error status

Raises:
  Exception: If scraping fails

scrape_urlr^   rH  python-sdk@r   rt   r   r   Nr   r   r   Tby_aliasexclude_noner   r   r   r   r   r   r   r}   rc   r   rf   r   r   r   zeroDataRetentionr   
/v1/scrape     @@rt   rP   r   r   r  r   Failed to scrape URL. Error: +Failed to parse Firecrawl response as JSON.z
scrape URLr3   )_validate_kwargs_prepare_headersversiondict_ensure_schema_dict
isinstanceupdaterequestspostr  status_coderP   getr   r   r  _handle_error)r  r^   r   rt   r  r  r  r  r   r   r   r  r  r  r   r  rc   r  rf   r  r  r  r  r   kwargs_headersscrape_paramsactionresponseresponse_jsons   &&$$$$$$$$$$$$$$$$$$$$$$,     r!   r  FirecrawlApp.scrape_url  s   @ 	fl3((* 3G9-
 '.M)$'.M)$+7M-(+7M-((/@M+,'/M)$'.M)$(0tRV(WM*%&,M(# ,3HM/0+2FM./ (1M*%%*M'" (1M*%..w7G'4((X-@$($<$<WX=N$O!2<Wd2K2KwQXQ]Q]gkz~Q]QM)$#33LAL,--(l2J)-)A)A,xBX)YX&;ElTX;Y;Y<_k_p_pz~  NR_p  `SM-( MT  (U  MT  CI*VT2J2JPVP[P[eix|P[P}(}  MT  (UM)$"PZ[rtxPyPy5L  @W  @\  @\  fj  y}  @\  @~M12&-M(#%,:M.)*1DM-.%*ZZDZ%QM'"V$%-	*B*BxS`ajSkGk151I1I-XaJbckJl1mM)$X.M)mM.J.Jx[hiv[wOw595M5Mm\iNjksNt5uM-(2 ==||nJ'-4-@Wv%)d	
 3&	O ( $$Y//Fm4K)BM&,ABB-#&CMRYDZC[$\]]#&CM?$STT x6O (UH  O MNNOs   !4O<>&P %P >*P Pr  rY  rZ  r[  rn   scrape_optionsc                   < V ^8  d   QhRS[ RS[S[,          RS[S[ ,          RS[S[ ,          RS[S[ ,          RS[S[ ,          RS[S[ ,          RS[S[,          R	S[S[,          R
S[/
# )r)   rX  r  rY  rZ  r[  rn   r   r   r  r  )r-   r   r   r   r^  )r.   r/   s   "r!   r0   r  d  s     ]3 ]3]3 C=	]3
 #]3 SM]3 3-]3 c]]3 sm]3 c]]3 %]3]3 (]3r2   c               2   V P                  V
R4       / pVe   W+R&   Ve   W;R&   Ve   WKR&   Ve   W[R&   Ve   WkR&   Ve   W{R&   Ve   WR	&   V	e   V	P                  R
R
R7      VR&   VP                  V
4       VP                  R4      p\	        RRV/VB pVP                  R
R
R7      pR\
         2VR&   V'       d   WR&   \        P                  ! V P                   R2RRV P                   2/VR7      pVP                  ^8X  de    VP                  4       pVP                  R4      '       d   RV9   d   \        R/ VB # RV9   d   \        RVR,           24      h\        RV 24      hV P                  VR4       R#   \         d    \        R4      hi ; i)a  
Search for content using Firecrawl.

Args:
    query (str): Search query string
    limit (Optional[int]): Max results (default: 5)
    tbs (Optional[str]): Time filter (e.g. "qdr:d")
    filter (Optional[str]): Custom result filter
    lang (Optional[str]): Language code (default: "en")
    country (Optional[str]): Country code (default: "us") 
    location (Optional[str]): Geo-targeting
    timeout (Optional[int]): Request timeout in milliseconds
    scrape_options (Optional[ScrapeOptions]): Result scraping configuration
    **kwargs: Additional keyword arguments for future compatibility

Returns:
    SearchResponse: Response containing:
        * success (bool): Whether request succeeded
        * data (List[FirecrawlDocument]): Search results
        * warning (Optional[str]): Warning message if any
        * error (Optional[str]): Error message if any

Raises:
    Exception: If search fails or response cannot be parsed
r   Nr  rY  rZ  r[  rn   r   r   Tr  r#  integrationrX  r  rH  
/v1/searchAuthorizationBearer rt   rP   r   r  r   zSearch failed. Error: r  r3   )r  r  r  r  rS  r  r  r  r  r  r  rP   r^  r   r  r  )r  rX  r  rY  rZ  r[  rn   r   r   r  r  search_params_integrationfinal_paramsparams_dictr  r  s   &&$$$$$$$$,      r!   r   FirecrawlApp.searchd  s   N 	fh/  %*'"?#&% &,(#$(&!'.)$(0*%'.)$%-;-@-@$]a-@-bM/* 	V$$((7 $A%A=A"''D'I"-gY 7H)5& ==||nJ'$~&>?
 3&	O ( $$Y//Fm4K):M::-#&<]7=S<T$UVV#&<]O$LMM x2  O MNNOs   &E? /E? *E? ?Finclude_pathsexclude_paths	max_depthmax_discovery_depthallow_backward_linkscrawl_entire_domainr  ignore_sitemapr   deduplicate_similar_urlsignore_query_parametersregex_on_full_urlr'  allow_subdomainsmax_concurrencypoll_intervalidempotency_keyc          ,        < V ^8  d   QhRS[ RS[S[S[ ,          ,          RS[S[S[ ,          ,          RS[S[,          RS[S[,          RS[S[,          RS[S[,          RS[S[,          R	S[S[,          R
S[S[,          RS[S[,          RS[S[S[ S[3,          ,          RS[S[,          RS[S[,          RS[S[,          RS[S[,          RS[S[,          RS[S[,          RS[S[,          RS[S[,          RS[S[ ,          RS[/# )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   rr   r0  )r.   r/   s   "r!   r0   r    se    @< @<@<  S	*	@<
  S	*@< C=@< &c]@< }@< 'tn@< &d^@< 'tn@< !@< !/@< %] 234@< #+4.@<  "*$!@<" $D>#@<$ }%@<& #4.'@<( "#)@<* &d^+@<,  }-@<. "#/@<2 
3@<r2   c                  V P                  VR4       / pVe   VVR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   M	Ve   VVR	&   V	e   V	VR
&   V
e   V
VR&   Ve   VP                  RRR7      VR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   VP                  V4       VP                  R4      p\	        R/ VB pVP                  RRR7      pVVR&   R\
         2VR&   V'       d   VVR&   V P                  V4      pV P                  V P                   R2VV4      pVP                  ^8X  d4    VP                  4       P                  R4      pT P                  TTT4      # V P                  VR4       R#    \        R4      h; i) a  
Crawl a website starting from a URL.

Args:
    url (str): Target URL to start crawling from
    include_paths (Optional[List[str]]): Patterns of URLs to include
    exclude_paths (Optional[List[str]]): Patterns of URLs to exclude
    max_depth (Optional[int]): Maximum crawl depth
    max_discovery_depth (Optional[int]): Maximum depth for finding new URLs
    limit (Optional[int]): Maximum pages to crawl
    allow_backward_links (Optional[bool]): DEPRECATED: Use crawl_entire_domain instead
    crawl_entire_domain (Optional[bool]): Follow parent directory links
    allow_external_links (Optional[bool]): Follow external domain links
    ignore_sitemap (Optional[bool]): Skip sitemap.xml processing
    scrape_options (Optional[ScrapeOptions]): Page scraping configuration
    webhook (Optional[Union[str, WebhookConfig]]): Notification webhook settings
    deduplicate_similar_urls (Optional[bool]): Remove similar URLs
    ignore_query_parameters (Optional[bool]): Ignore URL parameters
    regex_on_full_url (Optional[bool]): Apply regex to full URLs
    delay (Optional[int]): Delay in seconds between scrapes
    allow_subdomains (Optional[bool]): Follow subdomains
    max_concurrency (Optional[int]): Maximum number of concurrent scrapes
    zero_data_retention (Optional[bool]): Whether to delete data after 24 hours
    poll_interval (Optional[int]): Seconds between status checks (default: 2)
    idempotency_key (Optional[str]): Unique key to prevent duplicate requests
    **kwargs: Additional parameters to pass to the API

Returns:
    CrawlStatusResponse with:
    * Crawling status and progress
    * Crawled page contents
    * Success/error information

Raises:
    Exception: If crawl fails
	crawl_urlNr  r  r  r  r  r   r  r!  r"  Tr  r#  r   r$  r%  r&  r'  r)  r(  r  r  r^   r  rH  	/v1/crawlr  r  start crawl jobr3   )r  r  r  r  r  r  r  _post_requestr  r  rP   r   _monitor_job_statusr  )r  r^   r  r  r  r  r  r  r  r  r  r  r   r  r  r  r'  r  r  r  r  r  r  crawl_paramsr  r  r  rt   r  r  s   &&$$$$$$$$$$$$$$$$$$$$,       r!   r  FirecrawlApp.crawl_url  sX   ~ 	fk2 $+8L($+8L( '0L$*0CL,-$)L!*0CL,-!-1EL-.+1EL-.%,:L)%,:,?,?\`,?,aL)&-L##/5ML12".4KL01(->L)*$)L!'.>L*+&-<L)**0CL,-F##''6 #2\2"''D'I E"-gY 7H)5K& ''8%%i&@+wW3&P]]_((. ++BGGx):;	P"MOOs   *F0 0F=c          *        < V ^8  d   QhRS[ RS[S[S[ ,          ,          RS[S[S[ ,          ,          RS[S[,          RS[S[,          RS[S[,          RS[S[,          RS[S[,          R	S[S[,          R
S[S[,          RS[S[,          RS[S[S[ S[3,          ,          RS[S[,          RS[S[,          RS[S[,          RS[S[,          RS[S[,          RS[S[,          RS[S[,          RS[S[ ,          RS[/# )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   rr   r,  )r.   r/   s   "r!   r0   r  E  sV    z< z<z<  S	*	z<
  S	*z< C=z< &c]z< }z< 'tnz< &d^z< 'tnz< !z< !/z< %] 234z< #+4.z<  "*$!z<" $D>#z<$ }%z<& #4.'z<( "#)z<* &d^+z<, "#-z<0 
1z<r2   c                  V P                  VR4       / pVe   VVR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   M	Ve   VVR	&   V	e   V	VR
&   V
e   V
VR&   Ve   VP                  RRR7      VR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   VP                  V4       \        R/ VB pVP                  RRR7      pVVR&   R\         2VR&   V P                  V4      pV P                  V P                   R2VV4      pVP                  ^8X  d    \        R/ VP                  4       B # V P                  VR4       R#    \        R4      h; i)a  
Start an asynchronous crawl job.

Args:
    url (str): Target URL to start crawling from
    include_paths (Optional[List[str]]): Patterns of URLs to include
    exclude_paths (Optional[List[str]]): Patterns of URLs to exclude
    max_depth (Optional[int]): Maximum crawl depth
    max_discovery_depth (Optional[int]): Maximum depth for finding new URLs
    limit (Optional[int]): Maximum pages to crawl
    allow_backward_links (Optional[bool]): DEPRECATED: Use crawl_entire_domain instead
    crawl_entire_domain (Optional[bool]): Follow parent directory links
    allow_external_links (Optional[bool]): Follow external domain links
    ignore_sitemap (Optional[bool]): Skip sitemap.xml processing
    scrape_options (Optional[ScrapeOptions]): Page scraping configuration
    webhook (Optional[Union[str, WebhookConfig]]): Notification webhook settings
    deduplicate_similar_urls (Optional[bool]): Remove similar URLs
    ignore_query_parameters (Optional[bool]): Ignore URL parameters
    regex_on_full_url (Optional[bool]): Apply regex to full URLs
    delay (Optional[int]): Delay in seconds between scrapes
    allow_subdomains (Optional[bool]): Follow subdomains
    max_concurrency (Optional[int]): Maximum number of concurrent scrapes
    zero_data_retention (Optional[bool]): Whether to delete data after 24 hours
    idempotency_key (Optional[str]): Unique key to prevent duplicate requests
    **kwargs: Additional parameters to pass to the API

Returns:
    CrawlResponse with:
    * success - Whether crawl started successfully
    * id - Unique identifier for the crawl job
    * url - Status check URL for the crawl
    * error - Error message if start failed

Raises:
    Exception: If crawl initiation fails
async_crawl_urlNr  r  r  r  r  r   r  r!  r"  Tr  r#  r   r$  r%  r&  r'  r)  r(  r  r^   r  rH  r  r  r  r3   )r  r  r  r  r  r  r  r  r  r,  rP   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  rt   r  s   &&$$$$$$$$$$$$$$$$$$$,     r!   r  FirecrawlApp.async_crawl_urlE  s%   | 	f&78 $+8L($+8L( '0L$*0CL,-$)L!*0CL,-!-1EL-.+1EL-.%,:L)%,:,?,?\`,?,aL)&-L##/5ML12".4KL01(->L)*$)L!'.>L*+&-<L)**0CL,-F# #2\2"''D'I E"-gY 7H ''8%%i&@+wW3&P$7x}}77 x):;P"MOOs   E9 9Fc                &   < V ^8  d   QhRS[ RS[/# r)   r  r  r-   r0  )r.   r/   s   "r!   r0   r    s      Q? Q?S Q?-@ Q?r2   c                   RV 2pV P                  4       pV P                  V P                   V 2V4      pVP                  ^8X  Ed    VP	                  4       pTR,          R8X  d   RT9   d   TR,          pRT9   d   \        TR,          4      ^ 8X  d   MTP                  R4      pT'       g   \        P                  R4       M| T P                  Ys4      pTP                  ^8w  d$   \        P                  RTP                   24       M6 TP	                  4       p	TP                  T	P                  R. 4      4       T	pK  YeR&   RTP                  R4      RTP                  R4      RTP                  R4      RTP                  R4      RTP                  R4      RTP                  R4      /pRT9   d   TR,          TR&   RT9   d   TR,          TR&   \        RRRT9   d   RMR/TB # V P                  VR4       R
#    \        R4      h; i   \        R4      h; i  \
         d%   p
\        P                  R	T
 24        R
p
?
EK  R
p
?
ii ; i)a  
Check the status and results of a crawl job.

Args:
    id: Unique identifier for the crawl job

Returns:
    CrawlStatusResponse containing:

    Status Information:
    * status - Current state (scraping/completed/failed/cancelled)
    * completed - Number of pages crawled
    * total - Total pages to crawl
    * creditsUsed - API credits consumed
    * expiresAt - Data expiration timestamp
    
    Results:
    * data - List of crawled documents
    * next - URL for next page of results (if paginated)
    * success - Whether status check succeeded
    * error - Error message if failed

Raises:
    Exception: If status check fails

/v1/crawl/r  r  rv   r  r  Expected 'next' URL is missing.Failed to fetch next page: !Error during pagination request: Nr  r  r  r   r   FTcheck crawl statusr3   )r  _get_requestr  r  rP   r   lenr  r  r   r   extendr0  r  r  r  endpointrt   r  status_datar  next_urlstatus_response	next_dataes   &&         r!   check_crawl_statusFirecrawlApp.check_crawl_status  sN   4  t$'')$$~hZ%@'J3&P&mmo 8$3[(&v.D K/{623q8!#.??6#:'"NN+LM!".2.?.?.RO.::cA &/J?KfKfJg-h i %`,;,@,@,B	 !KK	fb(AB*3K +/' +//(31[__[9{}=[__[9/H +%$/$8!$#.v#6 & !(K!7T 
 x)=>aP"MOO$`&/2]&_ _  ) ""LL+LQC)PQ!"s=   	G= AH H #H =H
HH I(IIc                &   < V ^8  d   QhRS[ RS[/# r  r-   r4  )r.   r/   s   "r!   r0   r    s     ? ?S ?-@ ?r2   c                   V P                  4       pV P                  V P                   RV R2V4      pVP                  ^8X  d    \	        R/ VP                  4       B # V P                  VR4       R#    \        R4      h; i)a  
Returns information about crawl errors.

Args:
    id (str): The ID of the crawl job

Returns:
    CrawlErrorsResponse containing:
    * errors (List[Dict[str, str]]): List of errors with fields:
        - id (str): Error ID
        - timestamp (str): When the error occurred
        - url (str): URL that caused the error
        - error (str): Error message
    * robotsBlocked (List[str]): List of URLs blocked by robots.txt

Raises:
    Exception: If error check fails
r  /errorsr  zcheck crawl errorsNr3   r  r  r  r  r4  rP   r   r  r  r  rt   r  s   &&  r!   check_crawl_errorsFirecrawlApp.check_crawl_errors  s    & '')$$~Zt7%KWU3&P*=X]]_== x)=>P"MOO   A2 2A?c                <   < V ^8  d   QhRS[ RS[S[ S[3,          /# r  r-   r   r   )r.   r/   s   "r!   r0   r  1  s#     = =s =tCH~ =r2   c                    V P                  4       pV P                  V P                   RV 2V4      pVP                  ^8X  d    VP	                  4       # V P                  VR4       R#    \        R4      h; i)-  
Cancel an asynchronous crawl job.

Args:
    id (str): The ID of the crawl job to cancel

Returns:
    Dict[str, Any] containing:
    * success (bool): Whether cancellation was successful
    * error (str, optional): Error message if cancellation failed

Raises:
    Exception: If cancellation fails
r  r  zcancel crawl jobN)r  _delete_requestr  r  rP   r   r  r  s   &&  r!   cancel_crawlFirecrawlApp.cancel_crawl1  sz     '')''4<<.
2$(GQ3&P}}& x);<P"MOOs   A( (A5c          *        < V ^8  d   QhRS[ RS[S[S[ ,          ,          RS[S[S[ ,          ,          RS[S[,          RS[S[,          RS[S[,          RS[S[,          RS[S[,          R	S[S[,          R
S[S[,          RS[S[,          RS[S[S[ S[3,          ,          RS[S[,          RS[S[,          RS[S[,          RS[S[,          RS[S[,          RS[S[,          RS[S[,          RS[S[ ,          RR/# )r)   r^   r  r  r  r  r  r  r  r  r  r  r   r  r  r  r'  r  r  r  r  r  CrawlWatcher)r-   r   r   r   r   r   r   rr   )r.   r/   s   "r!   r0   r  J  sV    S9 S9S9 $DI.	S9
 $DI.S9  }S9 "*#S9 C=S9 #+4.S9 "*$S9 #+4.S9 %TNS9 %]3S9 eC$678S9 '/tnS9  &.d^!S9"  (~#S9$ C=%S9& 'tn'S9( &c])S9* "*$+S9, &c]-S90 
1S9r2   c               $   V P                   ! V3/ RVbRVbRVbRVbRVbRVbRVbRV	bR	V
bR
VbRVbRVbRVbRVbRVbRVbRVbRVbRVbVB pVP                  '       d)   VP                  '       d   \        VP                  V 4      # \	        R4      h)ag  
Initiate a crawl job and return a CrawlWatcher to monitor the job via WebSocket.

Args:
    url (str): Target URL to start crawling from
    include_paths (Optional[List[str]]): Patterns of URLs to include
    exclude_paths (Optional[List[str]]): Patterns of URLs to exclude
    max_depth (Optional[int]): Maximum crawl depth
    max_discovery_depth (Optional[int]): Maximum depth for finding new URLs
    limit (Optional[int]): Maximum pages to crawl
    allow_backward_links (Optional[bool]): DEPRECATED: Use crawl_entire_domain instead
    crawl_entire_domain (Optional[bool]): Follow parent directory links
    allow_external_links (Optional[bool]): Follow external domain links
    ignore_sitemap (Optional[bool]): Skip sitemap.xml processing
    scrape_options (Optional[ScrapeOptions]): Page scraping configuration
    webhook (Optional[Union[str, WebhookConfig]]): Notification webhook settings
    deduplicate_similar_urls (Optional[bool]): Remove similar URLs
    ignore_query_parameters (Optional[bool]): Ignore URL parameters
    regex_on_full_url (Optional[bool]): Apply regex to full URLs
    delay (Optional[int]): Delay in seconds between scrapes
    allow_subdomains (Optional[bool]): Follow subdomains
    max_concurrency (Optional[int]): Maximum number of concurrent scrapes
    zero_data_retention (Optional[bool]): Whether to delete data after 24 hours
    idempotency_key (Optional[str]): Unique key to prevent duplicate requests
    **kwargs: Additional parameters to pass to the API

Returns:
    CrawlWatcher: An instance to monitor the crawl job via WebSocket

Raises:
    Exception: If crawl job fails to start
r  r  r  r  r  r  r  r  r  r  r   r  r  r  r'  r  r  r  r  Crawl job failed to start)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  crawl_responses   &&$$$$$$$$$$$$$$$$$$$, r!   crawl_url_and_watch FirecrawlApp.crawl_url_and_watchJ  s   r --
'
 (
  	

 !4
 
 "6
 !4
 "6
 *
 *
 
 &>
 %<
 0
  !
" .#
$ ,%
& !4'
( ,+
. !!!n&7&7&7 1 1488788r2   r   include_subdomainssitemap_only	use_indexc                   < V ^8  d   QhRS[ RS[S[ ,          RS[S[,          RS[S[,          RS[S[,          RS[S[,          RS[S[,          RS[S[,          R	S[/	# )
r)   r^   r   r  r)  r*  r  r   r+  r  )r-   r   r   r   rA  )r.   r/   s   "r!   r0   r    s     X0 X0X0 SM	X0
 %TNX0 !)X0 #4.X0 C=X0 c]X0  ~X0 %X0r2   c                  V P                  V	R4       / p
Ve   W*R&   Ve   W:R&   Ve   WJR&   Ve   WZR&   Ve   WjR&   Ve   WzR&   Ve   WR	&   V
P                  V	4       V
P                  R
4      p\        R/ V
B pVP	                  RRR7      pWR&   R\
         2VR&   V'       d   WR
&   \        P                  ! V P                   R2RRV P                   2/VR7      pVP                  ^8X  de    VP                  4       pVP                  R4      '       d   RV9   d   \        R/ VB # RV9   d   \        RVR,           24      h\        RV 24      hV P                  VR4       R#   \         d    \        R4      hi ; i)a  
Map and discover links from a URL.

Args:
    url (str): Target URL to map
    search (Optional[str]): Filter pattern for URLs
    ignore_sitemap (Optional[bool]): Skip sitemap.xml processing
    include_subdomains (Optional[bool]): Include subdomain links
    sitemap_only (Optional[bool]): Only use sitemap.xml
    limit (Optional[int]): Maximum URLs to return
    timeout (Optional[int]): Request timeout in milliseconds
    **kwargs: Additional parameters to pass to the API

Returns:
    MapResponse: Response containing:
        * success (bool): Whether request succeeded
        * links (List[str]): Discovered URLs
        * error (Optional[str]): Error message if any

Raises:
    Exception: If mapping fails or response cannot be parsed
map_urlNr   r"  r<  r=  r  r   r>  r  Tr  r^   r  rH  /v1/mapr  r  r  r   rb   r   zMap failed. Error: r  mapr3   )r  r  r  r:  r  r  r  r  r  r  r  rP   rA  r   r  r  )r  r^   r   r  r)  r*  r  r   r+  r  
map_paramsr  r  r  r  r  s   &&$$$$$$$,      r!   r.  FirecrawlApp.map_url  s   F 	fi0 
 #)x %*8').@*+#(4}%"'w$+y! %.z" 	&!!~~m4 !.:."''D'I E"-gY 7H)5& ==||nG$$~&>?
 3&	O ( $$Y//G}4L&777-#&9-:P9Q$RSS#&9-$IJJ x/  O MNNOs   0&E' E' )*E' 'E>c          .        < V ^8  d   QhRS[ S[,          RS[S[ S[R,          ,          ,          RS[S[S[S[3,          ,          RS[S[ S[,          ,          RS[S[ S[,          ,          RS[S[,          RS[S[,          R	S[S[,          R
S[S[,          RS[S[,          RS[S[,          RS[S[,          RS[S[,          RS[S[R,          ,          RS[S[,          RS[S[,          RS[S[ S[	S[
S[S[S[S[S[S[S[S[3	,          ,          ,          RS[S[,          RS[S[,          RS[S[,          RS[S[,          RS[S[,          RS[/# )r)   urlsr   rc   rt   r  r  r  r  r   r   r   r  r  r  r   r  rf   r   r  r  r  r  r  	r_   r`   ra   r   rb   rd   r   rc   rP   r   r   r-   r   r   r   r   r   rl   r   r   r   r   r   r   r   r   r   r   r   r&   r  )r.   r/   s   "r!   r0   r    s    KC KC3iKC $w  (Q   R  S  T	KC
 $sCx.)KC tCy)KC tCy)KC $D>KC 3-KC #KC >*KC KC  (~KC 'tnKC D>KC   :;<!KC" *%#KC$ z*%KC& $uZ1A;P[]hjv  yE  G^  `i  &i   j  k  l'KC( %)KC*  }+KC, "#-KC. &d^/KC0 "#1KC4 
#5KCr2   c                  V P                  VR4       / pVe   VVR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   Ve   VVR	&   V	e   V	P                  R
R
R7      VR&   V
e   V
VR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   Vex   V P                  V4      p\        V\        4      '       d#   RV9   d   V P                  VR,          4      VR&   \        V\        4      '       d   TMVP                  R
R
R7      VR&   Vex   V P                  V4      p\        V\        4      '       d#   RV9   d   V P                  VR,          4      VR&   \        V\        4      '       d   TMVP                  R
R
R7      VR&   V'       d?   V Uu. uF.  p\        V\        4      '       d   TMVP                  R
R
R7      NK0  	  upVR&   Ve   VP                  R
R
R7      VR&   Ve   VVR&   Ve   VVR&   VP	                  V4       \        R / VB pVP                  R
R
R7      pVVR&   R\         2VR&   RV9   dG   VR,          '       d8   RVR,          9   d*   V P                  VR,          R,          4      VR,          R&   RV9   dG   VR,          '       d8   RVR,          9   d*   V P                  VR,          R,          4      VR,          R&   V P                  V4      pV P                  V P                   R2VV4      pVP                  ^8X  d4    VP                  4       P                  R4      pT P                  TTT4      # V P                  VR4       R# u upi    \        R4      h; i)!aF  
Batch scrape multiple URLs and monitor until completion.

Args:
    urls (List[str]): URLs to scrape
    formats (Optional[List[Literal]]): Content formats to retrieve
    headers (Optional[Dict[str, str]]): Custom HTTP headers
    include_tags (Optional[List[str]]): HTML tags to include
    exclude_tags (Optional[List[str]]): HTML tags to exclude
    only_main_content (Optional[bool]): Extract main content only
    wait_for (Optional[int]): Wait time in milliseconds
    timeout (Optional[int]): Request timeout in milliseconds
    location (Optional[LocationConfig]): Location configuration
    mobile (Optional[bool]): Use mobile user agent
    skip_tls_verification (Optional[bool]): Skip TLS verification
    remove_base64_images (Optional[bool]): Remove base64 encoded images
    block_ads (Optional[bool]): Block advertisements
    proxy (Optional[Literal]): Proxy type to use
    extract (Optional[JsonConfig]): Content extraction config
    json_options (Optional[JsonConfig]): JSON extraction config
    actions (Optional[List[Union]]): Actions to perform
    agent (Optional[AgentOptions]): Agent configuration
    max_concurrency (Optional[int]): Maximum number of concurrent scrapes
    poll_interval (Optional[int]): Seconds between status checks (default: 2)
    idempotency_key (Optional[str]): Unique key to prevent duplicate requests
    **kwargs: Additional parameters to pass to the API

Returns:
    BatchScrapeStatusResponse with:
    * Scraping status and progress
    * Scraped content for each URL
    * Success/error information

Raises:
    Exception: If batch scrape fails
batch_scrape_urlsNr   rt   r   r   r   r   r   Tr  r   r   r   r   r   r   r}   rc   r   rf   r   r(  r  r4  r  rH  /v1/batch/scraper  r  start batch scrape jobr3   )r  r  r  r  r  r   r  r  r  r  r  rP   r  r   r  r  )r  r4  r   rt   r  r  r  r  r   r   r   r  r  r  r   rc   r  rf   r   r  r  r  r  r  r  r  r  r  r  r  s   &&$$$$$$$$$$$$$$$$$$$$$,      r!   r8  FirecrawlApp.batch_scrape_urls  s   @ 	f&9: '.M)$'.M)$#+7M-(#+7M-((/@M+,'/M)$'.M)$(0tRV(WM*%&,M(# ,3HM/0+2FM./ (1M*%%*M'"..w7G'4((X-@$($<$<WX=N$O!2<Wd2K2KwQXQ]Q]gkz~Q]QM)$#33LAL,--(l2J)-)A)A,xBX)YX&;ElTX;Y;Y<_k_p_pz~  NR_p  `SM-( MT  (U  MT  CI*VT2J2JPVP[P[eix|P[P}(}  MT  (UM)$%*ZZDZ%QM'"&.=M*+*1DM-. 	V$ $4m4"''D'I"F"-gY 7H#I(>(>8{[dOeCe/3/G/GT]H^_gHh/iK	"8,K'K,F,F8WbcpWqKq373K3KKXeLfgoLp3qK&x0 ''8%%6F&GV]^3&P]]_((. ++BGGx)ABC (U:P"MOOs   4M& M+ +M8c          -        < V ^8  d   QhRS[ S[,          RS[S[ S[R,          ,          ,          RS[S[S[S[3,          ,          RS[S[ S[,          ,          RS[S[ S[,          ,          RS[S[,          RS[S[,          R	S[S[,          R
S[S[,          RS[S[,          RS[S[,          RS[S[,          RS[S[,          RS[S[R,          ,          RS[S[,          RS[S[,          RS[S[ S[	S[
S[S[S[S[S[S[S[S[3	,          ,          ,          RS[S[,          RS[S[,          RS[S[,          RS[S[,          RS[/# )r)   r4  r   rc   rt   r  r  r  r  r   r   r   r  r  r  r   r  rf   r   r  r  r  r  r5  r   r   r-   r   r   r   r   r   rl   r   r   r   r   r   r   r   r   r   r   r   r&   r  )r.   r/   s   "r!   r0   r    s    JC JC3iJC $w  (Q   R  S  T	JC
 $sCx.)JC tCy)JC tCy)JC $D>JC 3-JC #JC >*JC JC  (~JC 'tnJC D>JC   :;<!JC" *%#JC$ z*%JC& $uZ1A;P[]hjv  yE  G^  `i  &i   j  k  l'JC( %)JC* "#+JC, "#-JC. &d^/JC2 
3JCr2   c                  V P                  VR4       / pVe   VVR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   Ve   VVR	&   V	e   V	P                  R
R
R7      VR&   V
e   V
VR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   Vex   V P                  V4      p\        V\        4      '       d#   RV9   d   V P                  VR,          4      VR&   \        V\        4      '       d   TMVP                  R
R
R7      VR&   Vex   V P                  V4      p\        V\        4      '       d#   RV9   d   V P                  VR,          4      VR&   \        V\        4      '       d   TMVP                  R
R
R7      VR&   V'       d?   V Uu. uF.  p\        V\        4      '       d   TMVP                  R
R
R7      NK0  	  upVR&   Ve   VP                  R
R
R7      VR&   Ve   VVR&   Ve   VVR&   VP	                  V4       \        R/ VB pVP                  R
R
R7      pVVR&   R\         2VR&   RV9   dG   VR,          '       d8   RVR,          9   d*   V P                  VR,          R,          4      VR,          R&   RV9   dG   VR,          '       d8   RVR,          9   d*   V P                  VR,          R,          4      VR,          R&   V P                  V4      pV P                  V P                   R2VV4      pVP                  ^8X  d    \        R/ VP                  4       B # V P                  VR4       R# u upi    \        R4      h; i) at  
Initiate a batch scrape job asynchronously.

Args:
    urls (List[str]): URLs to scrape
    formats (Optional[List[Literal]]): Content formats to retrieve
    headers (Optional[Dict[str, str]]): Custom HTTP headers
    include_tags (Optional[List[str]]): HTML tags to include
    exclude_tags (Optional[List[str]]): HTML tags to exclude
    only_main_content (Optional[bool]): Extract main content only
    wait_for (Optional[int]): Wait time in milliseconds
    timeout (Optional[int]): Request timeout in milliseconds
    location (Optional[LocationConfig]): Location configuration
    mobile (Optional[bool]): Use mobile user agent
    skip_tls_verification (Optional[bool]): Skip TLS verification
    remove_base64_images (Optional[bool]): Remove base64 encoded images
    block_ads (Optional[bool]): Block advertisements
    proxy (Optional[Literal]): Proxy type to use
    extract (Optional[JsonConfig]): Content extraction config
    json_options (Optional[JsonConfig]): JSON extraction config
    actions (Optional[List[Union]]): Actions to perform
    agent (Optional[AgentOptions]): Agent configuration
    max_concurrency (Optional[int]): Maximum number of concurrent scrapes
    zero_data_retention (Optional[bool]): Whether to delete data after 24 hours
    idempotency_key (Optional[str]): Unique key to prevent duplicate requests
    **kwargs: Additional parameters to pass to the API

Returns:
    BatchScrapeResponse with:
    * success - Whether job started successfully
    * id - Unique identifier for the job
    * url - Status check URL
    * error - Error message if start failed

Raises:
    Exception: If job initiation fails
async_batch_scrape_urlsNr   rt   r   r   r   r   r   Tr  r   r   r   r   r   r   r}   rc   r   rf   r   r(  r  r4  r  rH  r9  r  r:  r3   )r  r  r  r  r  r   r  r  r  r  r  r  rP   r   r  )r  r4  r   rt   r  r  r  r  r   r   r   r  r  r  r   rc   r  rf   r   r  r  r  r  r  r  r  r  r  s   &&$$$$$$$$$$$$$$$$$$$$,     r!   r?  $FirecrawlApp.async_batch_scrape_urls  s   @ 	f&?@ '.M)$'.M)$#+7M-(#+7M-((/@M+,'/M)$'.M)$(0tRV(WM*%&,M(# ,3HM/0+2FM./ (1M*%%*M'"..w7G'4((X-@$($<$<WX=N$O!2<Wd2K2KwQXQ]Q]gkz~Q]QM)$#33LAL,--(l2J)-)A)A,xBX)YX&;ElTX;Y;Y<_k_p_pz~  NR_p  `SM-( MT  (U  MT  CI*VT2J2JPVP[P[eix|P[P}(}  MT  (UM)$%*ZZDZ%QM'"&.=M*+*1DM-. 	V$ $4m4"''D'I"F"-gY 7H#I(>(>8{[dOeCe/3/G/GT]H^_gHh/iK	"8,K'K,F,F8WbcpWqKq373K3KKXeLfgoLp3qK&x0 ''8%%6F&GV]^3&P*=X]]_== x)ABA (U:P"MOOs   4M M Mc          -        < V ^8  d   QhRS[ S[,          RS[S[ S[R,          ,          ,          RS[S[S[S[3,          ,          RS[S[ S[,          ,          RS[S[ S[,          ,          RS[S[,          RS[S[,          R	S[S[,          R
S[S[,          RS[S[,          RS[S[,          RS[S[,          RS[S[,          RS[S[R,          ,          RS[S[,          RS[S[,          RS[S[ S[	S[
S[S[S[S[S[S[S[S[3	,          ,          ,          RS[S[,          RS[S[,          RS[S[,          RS[S[,          RR/# )r)   r4  r   rc   rt   r  r  r  r  r   r   r   r  r  r  r   r  rf   r   r  r  r  r  r#  r5  r   )r   r-   r   r   r   r   r   rl   r   r   r   r   r   r   r   r   r   r   r   r&   )r.   r/   s   "r!   r0   r    s    JC JC3iJC $w  (Q   R  S  T	JC
 $sCx.)JC tCy)JC tCy)JC $D>JC 3-JC #JC >*JC JC  (~JC 'tnJC D>JC   :;<!JC" *%#JC$ z*%JC& $uZ1A;P[]hjv  yE  G^  `i  &i   j  k  l'JC( %)JC* "#+JC, &d^-JC. "#/JC2 
3JCr2   c               N   V P                  VR4       / pVe   VVR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   Ve   VVR	&   V	e   V	P                  R
R
R7      VR&   V
e   V
VR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   Vex   V P                  V4      p\        V\        4      '       d#   RV9   d   V P                  VR,          4      VR&   \        V\        4      '       d   TMVP                  R
R
R7      VR&   Vex   V P                  V4      p\        V\        4      '       d#   RV9   d   V P                  VR,          4      VR&   \        V\        4      '       d   TMVP                  R
R
R7      VR&   V'       d?   V Uu. uF.  p\        V\        4      '       d   TMVP                  R
R
R7      NK0  	  upVR&   Ve   VP                  R
R
R7      VR&   Ve   VVR&   Ve   VVR&   VP	                  V4       \        R / VB pVP                  R
R
R7      pVVR&   R\         2VR&   RV9   dG   VR,          '       d8   RVR,          9   d*   V P                  VR,          R,          4      VR,          R&   RV9   dG   VR,          '       d8   RVR,          9   d*   V P                  VR,          R,          4      VR,          R&   V P                  V4      pV P                  V P                   R2VV4      pVP                  ^8X  d`    \        R / VP                  4       B pVP                  '       d)   VP                  '       d   \        VP                  V 4      # \!        R4      hV P#                  VR4       R# u upi    \!        R4      h; i)!a6  
Initiate a batch scrape job and return a CrawlWatcher to monitor the job via WebSocket.

Args:
    urls (List[str]): URLs to scrape
    formats (Optional[List[Literal]]): Content formats to retrieve
    headers (Optional[Dict[str, str]]): Custom HTTP headers
    include_tags (Optional[List[str]]): HTML tags to include
    exclude_tags (Optional[List[str]]): HTML tags to exclude
    only_main_content (Optional[bool]): Extract main content only
    wait_for (Optional[int]): Wait time in milliseconds
    timeout (Optional[int]): Request timeout in milliseconds
    location (Optional[LocationConfig]): Location configuration
    mobile (Optional[bool]): Use mobile user agent
    skip_tls_verification (Optional[bool]): Skip TLS verification
    remove_base64_images (Optional[bool]): Remove base64 encoded images
    block_ads (Optional[bool]): Block advertisements
    proxy (Optional[Literal]): Proxy type to use
    extract (Optional[JsonConfig]): Content extraction config
    json_options (Optional[JsonConfig]): JSON extraction config
    actions (Optional[List[Union]]): Actions to perform
    agent (Optional[AgentOptions]): Agent configuration
    max_concurrency (Optional[int]): Maximum number of concurrent scrapes
    zero_data_retention (Optional[bool]): Whether to delete data after 24 hours
    idempotency_key (Optional[str]): Unique key to prevent duplicate requests
    **kwargs: Additional parameters to pass to the API

Returns:
    CrawlWatcher: An instance to monitor the batch scrape job via WebSocket

Raises:
    Exception: If batch scrape job fails to start
batch_scrape_urls_and_watchNr   rt   r   r   r   r   r   Tr  r   r   r   r   r   r   r}   rc   r   rf   r   r(  r  r4  r  rH  r9   Batch scrape job failed to startr  r:  r3   )r  r  r  r  r  r   r  r  r  r  r  r  rP   r   r  r#  r   r  )r  r4  r   rt   r  r  r  r  r   r   r   r  r  r  r   rc   r  rf   r   r  r  r  r  r  r  r  r  r  r&  s   &&$$$$$$$$$$$$$$$$$$$$,      r!   rC  (FirecrawlApp.batch_scrape_urls_and_watch  s   x 	f&CD '.M)$'.M)$#+7M-(#+7M-((/@M+,'/M)$'.M)$(0tRV(WM*%&,M(# ,3HM/0+2FM./ (1M*%%*M'"..w7G'4((X-@$($<$<WX=N$O!2<Wd2K2KwQXQ]Q]gkz~Q]QM)$#33LAL,--(l2J)-)A)A,xBX)YX&;ElTX;Y;Y<_k_p_pz~  NR_p  `SM-( MT  (U  MT  CI*VT2J2JPVP[P[eix|P[P}(}  MT  (UM)$%*ZZDZ%QM'"&.=M*+*1DM-. 	V$ $4m4"''D'I"F"-gY 7H#I(>(>8{[dOeCe/3/G/GT]H^_gHh/iK	"8,K'K,F,F8WbcpWqKq373K3KKXeLfgoLp3qK&x0 ''8%%6F&GV]^3&P!4!Gx}}!G!)))n.?.?.?'(9(94@@#$FGG x)ABI (UBP"MOOs   4N <N N 3N N$c                &   < V ^8  d   QhRS[ RS[/# r  r-   r  )r.   r/   s   "r!   r0   r    s      <F <FC <F4M <Fr2   c                   RV 2pV P                  4       pV P                  V P                   V 2V4      pVP                  ^8X  Ed    VP	                  4       pTR,          R8X  d   RT9   d   TR,          pRT9   d   \        TR,          4      ^ 8X  d   MTP                  R4      pT'       g   \        P                  R4       M| T P                  Ys4      pTP                  ^8w  d$   \        P                  RTP                   24       M6 TP	                  4       p	TP                  T	P                  R. 4      4       T	pK  YeR&   \        R/ RRT9   d   RMRRTP                  R4      RTP                  R4      RTP                  R4      RTP                  R4      RTP                  R4      RTP                  R4      RTP                  R4      RTP                  R4      /	B # V P                  VR4       R
#    \        R4      h; i   \        R4      h; i  \
         d$   p
\        P                  R	T
 24        R
p
?
K  R
p
?
ii ; i)z
Check the status of a batch scrape job using the Firecrawl API.

Args:
    id (str): The ID of the batch scrape job.

Returns:
    BatchScrapeStatusResponse: The status of the batch scrape job.

Raises:
    Exception: If the status check request fails.
/v1/batch/scrape/r  r  rv   r  r  r  r  r  Nr   r   FTr  r  r  zcheck batch scrape statusr3   )r  r  r  r  rP   r   r  r  r  r   r   r  r  r  r	  s   &&         r!   check_batch_scrape_status&FirecrawlApp.check_batch_scrape_status  s0    'rd+'')$$~hZ%@'J3&P&mmo 8$3[(&v.D K/{623q8!#.??6#:'"NN+LM!".2.?.?.RO.::cA &/J?KfKfJg-h i %`,;,@,@,B	 !KK	fb(AB*3K +/', 
G{$:5+//(31[__[9{}=[__[9//1
0 
 
 x)DEQP"MOO$`&/2]&_ _  ) ""LL+LQC)PQ!"s=   	G7 AH H #H 7HHH I"I  Ic                &   < V ^8  d   QhRS[ RS[/# r  r  )r.   r/   s   "r!   r0   r    s      F FC F4G Fr2   c                   V P                  4       pV P                  V P                   RV R2V4      pVP                  ^8X  d    \	        R/ VP                  4       B # V P                  VR4       R#    \        R4      h; i)a  
Returns information about batch scrape errors.

Args:
    id (str): The ID of the crawl job.

Returns:
    CrawlErrorsResponse containing:
    * errors (List[Dict[str, str]]): List of errors with fields:
      * id (str): Error ID
      * timestamp (str): When the error occurred
      * url (str): URL that caused the error
      * error (str): Error message
    * robotsBlocked (List[str]): List of URLs blocked by robots.txt

Raises:
    Exception: If the error check request fails
rI  r  r  zcheck batch scrape errorsNr3   r  r  s   &&  r!   check_batch_scrape_errors&FirecrawlApp.check_batch_scrape_errors  s    & '')$$~5Frd'%RT[\3&P*=X]]_== x)DEP"MOOr  r+   r}   r  Fr  r  c                  < V ^8  d   QhRS[ S[S[,          ,          RS[ S[,          RS[ S[,          RS[ S[,          RS[ S[,          RS[ S[,          RS[ S[,          RS[ S[S[S[3,          ,          R	S[S[,          /	# 
r)   r4  r+   r}   r  r  r  r  r   r  r   r   r-   r   r   r   rL  )r.   r/   s   "r!   r0   r    s     qN qN49%qN SM	qN
 SMqN $C=qN #+4.qN  (~qN #4.qN DcN+qN )-qNr2   c                  V P                  V	R4       V P                  4       p
V'       g   V'       g   \        R4      hV'       g   V'       g   \        R4      hV'       d   V P                  V4      pRT;'       g    . RVRVRVRVR	R
\	        4        2/pV'       d   W+R&   V'       d   WKR&   V'       d   WR&   VP                  V	4        V P                  V P                   R2VV
4      pVP                  ^8X  Ed    VP                  4       pTR,          '       d   TP                  R4      pT'       g   \        R4      h T P                  T P                   RT 2T
4      pTP                  ^8X  dY    TP                  4       pTR,          R8X  d   \        R / TB # TR,          R!9   d    \        RTR,           RTR,           24      hMT P                  TR4       \        P                   ! ^4       K  \        RTR,           24      hV P                  VR4        \        RRR7      #    \        R4      h; i   \        R4      h; i  \         d   p\        \#        T4      R4      hRp?ii ; i)"a4  
Extract structured information from URLs.

Args:
    urls (Optional[List[str]]): URLs to extract from
    prompt (Optional[str]): Custom extraction prompt
    schema (Optional[Any]): JSON schema/Pydantic model
    system_prompt (Optional[str]): System context
    allow_external_links (Optional[bool]): Follow external links
    enable_web_search (Optional[bool]): Enable web search
    show_sources (Optional[bool]): Include source URLs
    agent (Optional[Dict[str, Any]]): Agent configuration
    **kwargs: Additional parameters to pass to the API

Returns:
    ExtractResponse[Any] with:
    * success (bool): Whether request succeeded
    * data (Optional[Any]): Extracted data matching schema
    * error (Optional[str]): Error message if any

Raises:
    ValueError: If prompt/schema missing or extraction fails
rc   #Either prompt or schema is required!Either urls or prompt is requiredr4  r!  rG  rI  r}   rH  r  r+   r   r   /v1/extractr  r   r  )Job ID not returned from extract request./v1/extract/r  rv   Extract job 	. Error: r   zextract-statusFailed to extract. Error:   NFzInternal server error.r   r   r3   rw   r  )r  r  r  r  r"   r  r  r  r  rP   r   r  r  rL  r  timesleepr-   )r  r4  r+   r}   r  r  r  r  r   r  rt   request_datar  r  job_idr  r  r  s   &&$$$$$$$,        r!   rc   FirecrawlApp.extract  sy   H 	fi0'')fBCCF@AA--f5F DJJB "60<fKM?3
 %+"+8($)! 	F#)	*))<<.,H
 ##s*T#==?D 	??!XXd^F!'(STT *.*;*;#||nLA#+ +66#=`.=.B.B.D  +84C'6'E'E E!,X!6:Q!Q&/,{8?T>UU^_jkr_s^t0u&v v "R !..@PQ

1#&@g$PQQ""8Y7 u4LMMCT#&QSS`&/2]&_ _  	*SVS))	*s[   2I >H+ I I 6>I 5H; I A?I +H88I ;II I0I++I0c                6   < V ^8  d   QhRS[ RS[S[,          /# r)   rb  r  r-   rL  r   )r.   r/   s   "r!   r0   r  l  s      * * *1E *r2   c                T   V P                  4       p V P                  V P                   RV 2V4      pVP                  ^8X  d    \	        R/ VP                  4       B # V P                  VR4       R#    \        R4      h; i  \         d   p\        \        T4      R4      hRp?ii ; i)z
Retrieve the status of an extract job.

Args:
    job_id (str): The ID of the extract job.

Returns:
    ExtractResponse[Any]: The status of the extract job.

Raises:
    ValueError: If there is an error retrieving the status.
rX  r  zget extract statusr\  Nr3   )
r  r  r  r  rL  rP   r   r  r  r-   )r  rb  rt   r  r  s   &&   r!   get_extract_statusFirecrawlApp.get_extract_statusl  s     '')
	*((DLL>fX)NPWXH##s*T*=X]]_== ""8-ABT#&QSS  	*SVS))	*s/   2B A2 B 2A??B B'B""B'c                  < V ^8  d   QhRS[ S[S[,          ,          RS[ S[,          RS[ S[,          RS[ S[,          RS[ S[,          RS[ S[,          RS[ S[,          RS[ S[S[S[3,          ,          R	S[S[,          /	# rQ  rR  )r.   r/   s   "r!   r0   r    s     B* B*49%B* SM	B*
 SMB* $C=B* #+4.B*  (~B* #4.B* DcN+B* 8Gs7KB*r2   c                  V P                  4       p	TpV'       d   V P                  V4      pRVRVRVRVRVRR\         2/p
V'       d   W*R&   V'       d   WJR	&   V'       d   WR
&    V P                  V P                   R2W4      pVP
                  ^8X  d    \        R/ VP                  4       B # V P                  VR4       R#    \        R4      h; i  \         d   p\        \        T4      R4      hRp?ii ; i)a4  
Initiate an asynchronous extract job.

Args:
    urls (List[str]): URLs to extract information from
    prompt (Optional[str]): Custom extraction prompt
    schema (Optional[Any]): JSON schema/Pydantic model
    system_prompt (Optional[str]): System context
    allow_external_links (Optional[bool]): Follow external links
    enable_web_search (Optional[bool]): Enable web search
    show_sources (Optional[bool]): Include source URLs
    agent (Optional[Dict[str, Any]]): Agent configuration
    idempotency_key (Optional[str]): Unique key to prevent duplicate requests

Returns:
    ExtractResponse[Any] with:
    * success (bool): Whether request succeeded
    * data (Optional[Any]): Extracted data matching schema
    * error (Optional[str]): Error message if any

Raises:
    ValueError: If job initiation fails
r4  r!  rG  rI  r}   rH  r  r+   r   r   rV  r  zasync extractr\  Nr3   )r  r  r  r  r  r  rL  rP   r   r  r  r-   )r  r4  r+   r}   r  r  r  r  r   rt   ra  r  r  s   &&$$$$$$$    r!   async_extractFirecrawlApp.async_extract  s   D '')--f5F D "60<fG9-
 %+"+8($)!
	*))T\\N+*F^H##s*T*=X]]_== ""8_=T#&QSS  	*SVS))	*s0   &0C C 0C CC C9C44C9max_urlsshow_full_textrg  experimental_streamc                ~   < V ^8  d   QhRS[ RS[S[,          RS[S[,          RS[S[,          RS[S[,          RS[/# r)   r^   rn  ro  rg  rp  r  r-   r   r   r   r  )r.   r/   s   "r!   r0   r    s`     C CC sm	C
 %TNC D>C "*$C <ZCr2   c                  \        VVVVR7      pV P                  VVVVVR7      pVP                  '       d   VP                  '       g   \	        RRRRR7      # VP                  p V P                  V4      p	V	P                  R8X  d   V	# V	P                  R8X  d   V	# V	P                  R	8w  d   \	        RR
RRR7      # \        P                  ! ^4       Kp  )a  
Generate LLMs.txt for a given URL and poll until completion.

Args:
    url (str): Target URL to generate LLMs.txt from
    max_urls (Optional[int]): Maximum URLs to process (default: 10)
    show_full_text (Optional[bool]): Include full text in output (default: False)
    cache (Optional[bool]): Whether to use cached content if available (default: True)
    experimental_stream (Optional[bool]): Enable experimental streaming

Returns:
    GenerateLLMsTextStatusResponse with:
    * Generated LLMs.txt content
    * Full version if requested
    * Generation status
    * Success/error information

Raises:
    Exception: If generation fails
re  rf  rg  __experimental_stream)rn  ro  rg  rp  Fz#Failed to start LLMs.txt generationrw    r   r   r  r  rv   rP  /LLMs.txt generation job terminated unexpectedly)	rc  async_generate_llms_textr   r  r  check_generate_llms_text_statusr  r_  r`  )
r  r^   rn  ro  rg  rp  paramsr  rb  r  s
   &&$$$$    r!   generate_llms_textFirecrawlApp.generate_llms_text  s    8 ('"5	
 00) 3 1 
 x{{{1;	  99&AF}}+(*,.5!K# 	  JJqMr2   c                ~   < V ^8  d   QhRS[ RS[S[,          RS[S[,          RS[S[,          RS[S[,          RS[/# rr  r-   r   r   r   r  )r.   r/   s   "r!   r0   r    sX     8
 8
8
 sm	8

 %TN8
 D>8
 "*$8
 <T8
r2   c               
   \        VVVVR7      pV P                  4       pRV/VP                  RRR7      CpR\         2VR&    V P	                  V P
                   R2W4      p	V	P                  4       p
\        RV4       \        R	V
4       V
P                  R
4      '       d    \        R/ V
B # V P                  V
R4        \        RRR7      #    \        R4      h; i  \         d   p\        \        T4      4      hRp?ii ; i)a  
Initiate an asynchronous LLMs.txt generation operation.

Args:
    url (str): The target URL to generate LLMs.txt from. Must be a valid HTTP/HTTPS URL.
    max_urls (Optional[int]): Maximum URLs to process (default: 10)
    show_full_text (Optional[bool]): Include full text in output (default: False)
    cache (Optional[bool]): Whether to use cached content if available (default: True)
    experimental_stream (Optional[bool]): Enable experimental streaming

Returns:
    GenerateLLMsTextResponse: A response containing:
    * success (bool): Whether the generation initiation was successful
    * id (str): The unique identifier for the generation job
    * error (str, optional): Error message if initiation failed

Raises:
    Exception: If the generation job initiation fails.
ru  r^   Tr  r  rH  /v1/llmstxt	json_datar  r   r  zstart LLMs.txt generationNFInternal server errorr]  r3   )rc  r  r  r  r  r  rP   r   r  r  r   r  r  r-   )r  r^   rn  ro  rg  rp  r|  rt   r  reqr  r  s   &&$$$$      r!   rz  %FirecrawlApp.async_generate_llms_text  s   6 ('"5	
 '')CQ6;;4;#PQ	 +G95	(	%$$~[%A9VCxxzH+y)*h'||I&&S3?h?? ""8-HI ()
 	
S#$QRR  	%SV$$	%s1   AC #
C .C CC D)C==Dc                &   < V ^8  d   QhRS[ RS[/# r  r-   r  )r.   r/   s   "r!   r0   r  I  s      ${ ${# ${:X ${r2   c                   V P                  4       p V P                  V P                   RV 2V4      pVP                  ^8X  d    VP	                  4       p\        R/ VB # VP                  R8X  d   \        R4      hV P                  VR4        \        RRR	R
R7      #   \         d   p\        R\        T4       24      hRp?ii ; i  \         d   p\        \        T4      4      hRp?ii ; i)a  
Check the status of a LLMs.txt generation operation.

Args:
    id (str): The unique identifier of the LLMs.txt generation job to check status for.

Returns:
    GenerateLLMsTextStatusResponse: A response containing:
    * success (bool): Whether the generation was successful
    * status (str): Status of generation ("processing", "completed", "failed")
    * data (Dict[str, str], optional): Generated text with fields:
      * llmstxt (str): Generated LLMs.txt content
      * llmsfulltxt (str, optional): Full version if requested
    * error (str, optional): Error message if generation failed
    * expiresAt (str): When the generated data expires

Raises:
    Exception: If the status check fails.
/v1/llmstxt/zFFailed to parse Firecrawl response as GenerateLLMsTextStatusResponse: N  z!LLMs.txt generation job not foundz check LLMs.txt generation statusFr  rw   rw  rx  r3   )
r  r  r  r  rP   r  r   r-   r  r  )r  r  rt   r  r  r  s   &&    r!   r{  ,FirecrawlApp.check_generate_llms_text_statusI  s    ( '')	%((DLL>bT)JGTH##s*w (I9FIFF %%, CDD""8-OP .eCZckwyzz ! w#&lmpqrmslt$uvvw  	%SV$$	%s;   2C B  .C C)C  CC C,C''C,c                L   < V ^8  d   QhRS[ S[,          RS[S[S[3,          /# )r)   r  r  )r   r-   r   )r.   r/   s   "r!   r0   r  o  s)     
 
%c]
6:38n
r2   c                b    V'       d   RRRRV P                    2RV/# RRRRV P                    2/# )z
Prepare the headers for API requests.

Args:
    idempotency_key (Optional[str]): A unique key to ensure idempotency of requests.

Returns:
    Dict[str, str]: The headers including content type, authorization, and optionally idempotency key.
zContent-Typezapplication/jsonr  r  zx-idempotency-key)r  )r  r  s   &&r!   r  FirecrawlApp._prepare_headerso  sN      274<<.!9#_  .wt||n5
 	
r2   c                ~   < V ^8  d   QhRS[ RS[S[ S[3,          RS[S[ S[ 3,          RS[RS[RS[P                  /# r)   r^   r  rt   retriesbackoff_factorr  )r-   r   r   r   r   r  Response)r.   r/   s   "r!   r0   r    s]       sCx. #s(^	
  " -5,=,=r2   c                    \        V4       F~  p\        P                  ! YTRV9   d#   VR,          e   VR,          R,          ^,           MRR7      pVP                  R8X  d'   \        P
                  ! V^V,          ,          4       K|  Vu # 	  X# )a  
Make a POST request with retries.

Args:
    url (str): The URL to send the POST request to.
    data (Dict[str, Any]): The JSON data to include in the POST request.
    headers (Dict[str, str]): The headers to include in the POST request.
    retries (int): Number of retries for the request.
    backoff_factor (float): Backoff factor for retries.

Returns:
    requests.Response: The response from the POST request.

Raises:
    requests.RequestException: If the request fails after the specified retries.
r   Nr  r    )ranger  r  r  r_  r`  )r  r^   r  rt   r  r  attemptr  s   &&&&&&  r!   r  FirecrawlApp._post_request  s    . W~G}}Sqz  C  rC  HL  MV  HW  HcPTU^P_bhPhklPl  im  oH##s*

>Q'\:; & r2   c          
      b   < V ^8  d   QhRS[ RS[S[ S[ 3,          RS[RS[RS[P
                  /# r)   r^   rt   r  r  r  r-   r   r   r   r  r  )r.   r/   s   "r!   r0   r    K       #s(^ 	
 "
 -5,=,=r2   c                    \        V4       FS  p\        P                  ! WR7      pVP                  R8X  d'   \        P
                  ! V^V,          ,          4       KQ  Vu # 	  X# )a  
Make a GET request with retries.

Args:
    url (str): The URL to send the GET request to.
    headers (Dict[str, str]): The headers to include in the GET request.
    retries (int): Number of retries for the request.
    backoff_factor (float): Backoff factor for retries.

Returns:
    requests.Response: The response from the GET request.

Raises:
    requests.RequestException: If the request fails after the specified retries.
rt   r  )r  r  r  r  r_  r`  r  r^   rt   r  r  r  r  s   &&&&&  r!   r  FirecrawlApp._get_request  sO    * W~G||C9H##s*

>Q'\:; & r2   c          
      b   < V ^8  d   QhRS[ RS[S[ S[ 3,          RS[RS[RS[P
                  /# r  r  )r.   r/   s   "r!   r0   r    r  r2   c                    \        V4       FS  p\        P                  ! WR7      pVP                  R8X  d'   \        P
                  ! V^V,          ,          4       KQ  Vu # 	  X# )a  
Make a DELETE request with retries.

Args:
    url (str): The URL to send the DELETE request to.
    headers (Dict[str, str]): The headers to include in the DELETE request.
    retries (int): Number of retries for the request.
    backoff_factor (float): Backoff factor for retries.

Returns:
    requests.Response: The response from the DELETE request.

Raises:
    requests.RequestException: If the request fails after the specified retries.
r  r  )r  r  deleter  r_  r`  r  s   &&&&&  r!   r  FirecrawlApp._delete_request  sO    * W~Gs<H##s*

>Q'\:; & r2   c                H   < V ^8  d   QhRS[ RS[S[ S[ 3,          RS[RS[/# r)   r  rt   r  r  r-   r   r   r0  )r.   r/   s   "r!   r0   r    sA     2J 2J2J #s(^2J 	2J $7	2Jr2   c                    V P                    RV 2pV P                  WB4      pVP                  ^8X  d    VP                  4       pTR,          R8X  d   RT9   d   TR,          pRT9   df   \        TR,          4      ^ 8X  d   MMT P                  TR,          T4      p TP                  4       pTP                  TP                  R. 4      4       Kl  YvR&   \        R
/ TB # \	        R4      hTR,          R9   d&   \        T^4      p\        P                  ! T4       EK  \	        RTR,           24      hV P                  VR	4       EKF     \	        R4      h; i   \	        R4      h; i)a  
Monitor the status of a crawl job until completion.

Args:
    id (str): The ID of the crawl job.
    headers (Dict[str, str]): The headers to include in the status check requests.
    poll_interval (int): Seconds between status checks.

Returns:
    CrawlStatusResponse: The crawl results if the job is completed successfully.

Raises:
    Exception: If the job fails or an error occurs during status checks.
r  r  r  rv   r  r  z,Crawl job completed but no data was returnedz)Crawl job failed or was stopped. Status: r  r3   activepausedpendingqueuedwaitingr  )r  r  r  rP   r   r  r  r  r0  maxr_  r`  r  )r  r  rt   r  r  r  r  r  s   &&&&    r!   r   FirecrawlApp._monitor_job_status  sk   & j5G"//AO**c1T"1"6"6"8K x(K7,*62$3";v#671< %.2.?.?F@SU\.]O`.=.B.B.D !KK(CD.2F+2A[AA'(VWW *.nn"%mA"6MJJ}-#&OP[\dPeOf$ghh""?4HI1T#&QSS`&/2]&_ _s   E E EE$c                >   < V ^8  d   QhRS[ P                  RS[RR/# r)   r  r  r  N)r  r  r-   )r.   r/   s   "r!   r0   r  	  s4     #H #H''#H #H !#Hr2   c                    VP                  4       pVP                  RR4      pVP                  RR4      pT P                  TP                  Y$T4      p\        P                  P                  YqR7      h    TP                  R,          pTP                  4       '       d   RT 2pRTP                   2p LRTP                   2pR	p L  \
         d    R
TP                   2pR	p  Li ; i; i)a0  
Handle errors from API responses.

Args:
    response (requests.Response): The response object from the API request.
    action (str): Description of the action that was being performed.

Raises:
    Exception: An exception with a message containing the status code and error details from the response.
r   No error message provided.details%No additional error details provided.:Ni  Nz#Server returned non-JSON response: zFull response status: z+Server returned empty response with status zNo additional details availablez0Server returned unreadable response with status )r  )
rP   r  r   r   r  r  _get_error_messager  
exceptions	HTTPError)r  r  r  r  error_messageerror_detailsresponse_textmessages   &&&     r!   r  FirecrawlApp._handle_error	  s    	B$MMOM)--g7STM)--i9`aM ))(*>*>Wde !!++G+GG#	B
B (d 3 &&((&I-$YM&<X=Q=Q<R$SM&QRZRfRfQg$hM$EM B"RS[SgSgRh i ABs/   4A3 3C+6=C5CC($C+'C((C+c          
      8   < V ^8  d   QhRS[ RS[RS[RS[RS[/# r)   r  r  r  r  r  r   r-   )r.   r/   s   "r!   r0   r  9	  s9     u uc u3 us ucf ukn ur2   c                    VR8X  d   RV RV RV 2# VR8X  d   RV RV RV 2# VR8X  d   RV R	V RV 2# VR
8X  d   RV RV RV 2# VR8X  d   RV RV RV 2# RV RV RV RV 2# )a  
Generate a standardized error message based on HTTP status code.

Args:
    status_code (int): The HTTP status code from the response
    action (str): Description of the action that was being performed
    error_message (str): The error message from the API response
    error_details (str): Additional error details from the API response
    
Returns:
    str: A formatted error message
i  zPayment Required: Failed to z. z - r  z!Website Not Supported: Failed to i  zRequest Timeout: Failed to z as the request timed out. i  zConflict: Failed to z due to a conflict. r\  z!Internal Server Error: Failed to zUnexpected error during z: Status code r3   r  r  r  r  r  s   &&&&&r!   r  FirecrawlApp._get_error_message9	  s     #1&M?#m_]]C6vhbsS`RabbC08STaSbbefsetuuC)&1Em_TWXeWfggC6vhbsS`Rabb-fX^K=PRS`Raaderdsttr2   
time_limitanalysis_prompt(_FirecrawlApp__experimental_stream_stepson_activity	on_sourcec                .  < V ^8  d   QhRS[ RS[S[,          RS[S[,          RS[S[,          RS[S[ ,          RS[S[ ,          RS[S[,          RS[S[S[S[ S[3,          .R	3,          ,          R
S[S[S[S[ S[3,          .R	3,          ,          RS[/
# )r)   rX  r  r  rn  r  r  r  r  Nr  r  r-   r   r   r   r   r   r   rx  )r.   r/   s   "r!   r0   r  S	  s     ^X ^X^X  }	^X
 !^X sm^X &c]^X $C=^X *2$^X "(DcN+;T+A"BC^X  $sCx.)94)? @A^X Nh^Xr2   c          	        / p
Ve   W*R&   Ve   W:R&   Ve   WJR&   Ve   WZR&   Ve   WjR&   Ve   WzR&   \        R/ V
B p
V P                  VVVVVVR7      pVP                  R	4      '       d   R
V9  d   V# VR
,          p^ p^ p V P                  V4      pV'       d7   RV9   d0   VR,          VR pV F  pV! V4       K  	  \	        VR,          4      pV	'       d7   RV9   d0   VR,          VR pV F  pV	! V4       K  	  \	        VR,          4      pVR,          R8X  d   V# VR,          R8X  d   \        RVP                  R4       24      hVR,          R8w  d   M\        P                  ! ^4       K  R	RRR/# )  
Initiates a deep research operation on a given query and polls until completion.

Args:
    query (str): Research query or topic to investigate
    max_depth (Optional[int]): Maximum depth of research exploration
    time_limit (Optional[int]): Time limit in seconds for research
    max_urls (Optional[int]): Maximum number of URLs to process
    analysis_prompt (Optional[str]): Custom prompt for analysis
    system_prompt (Optional[str]): Custom system prompt
    __experimental_stream_steps (Optional[bool]): Enable experimental streaming
    on_activity (Optional[Callable]): Progress callback receiving {type, status, message, timestamp, depth}
    on_source (Optional[Callable]): Source discovery callback receiving {url, title, description}

Returns:
    DeepResearchStatusResponse containing:
    * success (bool): Whether research completed successfully
    * status (str): Current state (processing/completed/failed)
    * error (Optional[str]): Error message if failed
    * id (str): Unique identifier for the research job
    * data (Any): Research findings and analysis
    * sources (List[Dict]): List of discovered sources
    * activities (List[Dict]): Research progress log
    * summaries (List[str]): Generated research summaries

Raises:
    Exception: If research fails
Nr  rm  re  rn  r   __experimental_streamStepsr  r  rn  r  r  r   r  r{  rN  r  rv   rw   Deep research failed. Error: r   rP  F)Deep research job terminated unexpectedlyr3   )rk  async_deep_researchr  check_deep_research_statusr  r   r_  r`  )r  rX  r  r  rn  r  r  r  r  r  research_paramsr  rb  last_activity_countlast_source_countr  new_activitiesactivitynew_sourcessources   &&$$$$$$$$          r!   deep_researchFirecrawlApp.deep_researchS	  s   P  *3J'!+5K()1I&&0?,-$.;N+&2<W89,??++!+' , 
 ||I&&$h*>O$44V<F|v5!'!56I6J!K .H) !/&)&*>&?#Y&0$Y/0A0BC)Ff% *$'y(9$:!h;.!X-"?

7@S?T UVV!\1JJqM5'+VWWr2   c                   < V ^8  d   QhRS[ RS[S[,          RS[S[,          RS[S[,          RS[S[ ,          RS[S[ ,          RS[S[,          RS[S[ S[3,          /# )	r)   rX  r  r  rn  r  r  r  r  r-   r   r   r   r   r   )r.   r/   s   "r!   r0   r  	  s     ED EDED  }	ED
 !ED smED &c]ED $C=ED *2$ED DHS>EDr2   c                  / pVe   W(R&   Ve   W8R&   Ve   WHR&   Ve   WXR&   Ve   WhR&   Ve   WxR&   \        R/ VB pV P                  4       p	RV/VP                  R	R	R
7      Cp
R\         2V
R&   RV
9   dS   V
R,          pV'       dB   RV9   d;   \	        VR,          R4      '       d"   VR,          P                  4       V
R,          R&    V P                  V P                   R2W4      pVP                  ^8X  d    VP                  4       # V P                  VR4        RRRR/#    \        R4      h; i  \         d   p\        \        T4      4      hRp?ii ; i)2  
Initiates an asynchronous deep research operation.

Args:
    query (str): Research query or topic to investigate
    max_depth (Optional[int]): Maximum depth of research exploration
    time_limit (Optional[int]): Time limit in seconds for research
    max_urls (Optional[int]): Maximum number of URLs to process
    analysis_prompt (Optional[str]): Custom prompt for analysis
    system_prompt (Optional[str]): Custom system prompt
    __experimental_stream_steps (Optional[bool]): Enable experimental streaming

Returns:
    Dict[str, Any]: A response containing:
    * success (bool): Whether the research initiation was successful
    * id (str): The unique identifier for the research job
    * error (str, optional): Error message if initiation failed

Raises:
    Exception: If the research initiation fails.
Nr  rm  re  rn  r   r  rX  Tr  r  rH  r   r}   /v1/deep-researchr  zstart deep researchr   Fr   r  r3   )rk  r  r  r  hasattrr}   r  r  r  rP   r   r  r  r-   )r  rX  r  r  rn  r  r  r  r  rt   r  	json_optsr  r  s   &&$$$$$$      r!   r   FirecrawlApp.async_deep_research	  s   >  *3J'!+5K()1I&&0?,-$.;N+&2<W89,??'')e^';';TX\';']^	 +G95	( I%!-0IX2wy?RT\7]7]5>x5H5O5O5Q	-(2
	%))T\\N:K*LiaH##s*S#==?* ""8-BC 5'+BCCS#$QRR  	%SV$$	%s0   0D5 <D% D5 %D22D5 5E EEc                &   < V ^8  d   QhRS[ RS[/# r  r-   rx  )r.   r/   s   "r!   r0   r  	  s      (D (DS (D5O (Dr2   c                   V P                  4       p V P                  V P                   RV 2V4      pVP                  ^8X  d    VP	                  4       # VP                  R8X  d   \        R4      hV P                  VR4        RRR	R
/#    \        R4      h; i  \
         d   p\        \        T4      4      hRp?ii ; i)g  
Check the status of a deep research operation.

Args:
    id (str): The ID of the deep research operation.

Returns:
    DeepResearchResponse containing:

    Status:
    * success - Whether research completed successfully
    * status - Current state (processing/completed/failed)
    * error - Error message if failed
    
    Results:
    * id - Unique identifier for the research job
    * data - Research findings and analysis
    * sources - List of discovered sources
    * activities - Research progress log
    * summaries - Generated research summaries

Raises:
    Exception: If the status check fails.
/v1/deep-research/r  r  zDeep research job not foundzcheck deep research statusNr   Fr   r  )	r  r  r  r  rP   r   r  r  r-   )r  r  rt   r  r  s   &&   r!   r  'FirecrawlApp.check_deep_research_status	  s    2 '')	%((DLL>9KB4)PRYZH##s*S#==?* %%, =>>""8-IJ 5'+BCCS#$QRR
  	%SV$$	%s/   2B B
 .B 
BB B>%B99B>c                @   < V ^8  d   QhRS[ S[S[3,          RS[RR/# )r)   r  method_namer  Nr   r-   r   )r.   r/   s   "r!   r0   r  $
  s/     .l .ltCH~ .lC .lD .lr2   c                $   V'       g   R# R0 RmR0 RmR0 RmR0 RmR0 RmR0 RmR0 RmR	0 Rm/pVP                  V\        4       4      p\        VP                  4       4      V,
          pV'       d"   \        R
V RRP	                  V4       R24      hR# )ah  
Validate additional keyword arguments before they are passed to the API.
This provides early validation before the Pydantic model validation.

Args:
    kwargs (Dict[str, Any]): Additional keyword arguments to validate
    method_name (str): Name of the method these kwargs are for

Raises:
    ValueError: If kwargs contain invalid or unsupported parameters
Nr  rc   r   r  r.  r8  r?  rC  zUnsupported parameter(s) for z: z, zC. Please refer to the API documentation for the correct parameters.>   r   r   r   rf   rc   r   r  r   r   r  r  r  r  r  r  r  r  r  r  >	   rY  r[  r  rZ  rn   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  r  r  >   r   r   r   rf   rc   r   rt   r   r   r   r  r  r  r  r  r  r  r  )r  setkeysr  r   )r  r  r  method_paramsallowed_paramsunknown_paramss   &&&   r!   r  FirecrawlApp._validate_kwargs$
  s       T {  |  R "@ & (F * ,J%
2 '**;> V[[]+n<<[MDIIVdLeKf  gj  k  l  l r2   c                   Vf   V# \        V\        4      '       dE   \        VR4      '       d   VP                  4       # \        VR4      '       d   VP	                  4       # \        V\
        4      '       d4   VP                  4        UUu/ uF  w  r#W P                  V4      bK  	  upp# \        V\        \        34      '       d!   V Uu. uF  q0P                  V4      NK  	  up# V# u uppi u upi )zg
Utility to ensure a schema is a dict, not a Pydantic model class. Recursively checks dicts and lists.
model_json_schemar}   )
r  r   r  r  r}   r  itemsr  listtuple)r  r}   kvs   &&  r!   r   FirecrawlApp._ensure_schema_dictW
  s     >Mfd##v233//11**}}&fd##?E||~N~tqA//22~NNftUm,,9?@A,,Q/@@ O@s   
C(
C.)r  r  NNN         ?)'r4   r5   r6   r7   r  r  r   r  r  r  r  r   r'  r.  r8  r?  rC  rJ  rN  rc   rh  rl  r}  rz  r{  r  r  r  r  r  r  r  r  r  r  r  r  r:   r;   r<   s   @r!   r  r    sN
    O O$Y7 mq	Y7
 15Y7 15Y7 15Y7 15Y7 '+Y7 &+Y7 26Y7 &*Y7 59Y7 48Y7 )-Y7  DH!Y7" )-#Y7$ -1%Y7& 26'Y7( sw)Y7* HL+Y7, &*-Y7. .2/Y70 371Y72 -13Y7 Y7v]3 $(	]3
 "&]3 %)]3 #']3 &*]3 '+]3 &+]3 7;]3 ]3~@< .2	@<
 .2@< $(@< .2@<  $@< 04@< /3@< 04@< *.@< 37@< 8<@< 48@<  37!@<" -1#@<$  $%@<& ,0'@<( *.)@<* /3+@<, ()-@<. *./@< @<Dz< .2	z<
 .2z< $(z< .2z<  $z< 04z< /3z< 04z< *.z< 37z< 8<z< 48z<  37!z<" -1#z<$  $%z<& ,0'z<( *.)z<* /3+z<, *.-z< z<xQ? Q?f? ?:= =2S9 26	S9
 26S9 (,S9 26S9 $(S9 48S9 37S9 48S9 .2S9 7;S9 <@S9 8<S9  7;!S9" 15#S9$ $(%S9& 04'S9( .2)S9* 37+S9, .2-S9 S9jX0 %)	X0
 .2X0 26X0 ,0X0 $(X0 &+X0 )-X0 X0tKC W[	KC
 -1KC -1KC -1KC -1KC #'KC "'KC .2KC "&KC 15KC 04KC %)KC  @D!KC" )-#KC$ .2%KC& os'KC( )-)KC* ()+KC, *.-KC. /3/KC0 *.1KC KCZJC W[	JC
 -1JC -1JC -1JC -1JC #'JC "'JC .2JC "&JC 15JC 04JC %)JC  @D!JC" )-#JC$ .2%JC& os'JC( )-)JC* *.+JC, *.-JC. /3/JC JCXJC W[	JC
 -1JC -1JC -1JC -1JC #'JC "'JC .2JC "&JC 15JC 04JC %)JC  @D!JC" )-#JC$ .2%JC& os'JC( )-)JC* *.+JC, /3-JC. *./JC JCX<F <F|F F:qN %)	qN
 %)qN ,0qN 49qN 16qN ,1qN /3qN qNf* *4B* %)	B*
 %)B* ,0B* 49B* 16B* ,1B* /3B* B*HC '+	C
 .2C %)C 37C CJ8
 '+	8

 .28
 %)8
 378
 8
t${ ${L
 
0 > : :2J 2Jh#H #HJu u4^X (,	^X
 )-^X '+^X .2^X ,0^X ;?^X GK^X EI^X ^X@ED (,	ED
 )-ED '+ED .2ED ,0ED ;?ED EDN(D (DT.l .lf r2   r  c                      a  ] tR tRt o RtV 3R lR ltV 3R lR ltV 3R lR ltV 3R	 lR
 ltV 3R lR lt	V 3R lR lt
RtV tR# )r#  ii
  a  
A class to watch and handle crawl job events via WebSocket connection.

Attributes:
    id (str): The ID of the crawl job to watch
    app (FirecrawlApp): The FirecrawlApp instance
    data (List[Dict[str, Any]]): List of crawled documents/data
    status (str): Current status of the crawl job
    ws_url (str): WebSocket URL for the crawl job
    event_handlers (dict): Dictionary of event type to list of handler functions
c                &   < V ^8  d   QhRS[ RS[/# r)   r  app)r-   r  )r.   r/   s   "r!   r0   CrawlWatcher.__annotate__u
  s     

 

3 

\ 

r2   c                    Wn         W n        . V n        R V n        VP                  P                  RR4       RV 2V n        R. R. R. /V n        R# )r  httpwsr  doner   documentN)r  r  r  r  r  replacews_urlevent_handlers)r  r  r  s   &&&r!   r  CrawlWatcher.__init__u
  sW    *,	 ,,VT:;:bTJBR
r2   c                   < V ^8  d   QhRR/# r)   r  Nr3   )r.   r/   s   "r!   r0   r  
  s     	* 	*t 	*r2   c                B  "   \         P                  ! V P                  RRRV P                  P                   23.R7      ;_uu_4       GRj  xL
 pV P                  V4      G Rj  xL
  RRR4      GRj  xL
  R#  L/ L L
  + GRj  xL 
 '       g   i     R# ; i5i)zE
Establishes WebSocket connection and starts listening for messages.
Nr  r  )max_sizeadditional_headers
websocketsconnectr  r  r  _listenr  	websockets   & r!   r  CrawlWatcher.connect
  s      %%KK!0GDHH<L<L;M2N OP
 
 
 ,,y)))
 
 

 *
 
 
 
s`   A
BA<BB%A>&B*B5B 6B>B BB	B	
B	B		Bc                   < V ^8  d   QhRR/# r  r3   )r.   r/   s   "r!   r0   r  
       	, 	,$ 	,r2   c                   "   V  Rj  xL
  p\         P                  ! V4      pV P                  V4      G Rj  xL
  K;   L6 LD9R# 5i)zq
Listens for incoming WebSocket messages and handles them.

Args:
    websocket: The WebSocket connection object
NrP   loads_handle_messager  r  r  msgs   &&  r!   r  CrawlWatcher._listen
  E      ' 	, 	,'**W%C&&s+++	,+ '5   AAA A,AAA AAAc                V   < V ^8  d   QhRS[ RS[S[S[ S[3,          .R3,          RR/# )r)   
event_typehandlerNr  )r-   r   r   r   )r.   r/   s   "r!   r0   r  
  s9     	< 	<S 	<8T#s(^DTVZDZ;[ 	<`d 	<r2   c                n    WP                   9   d%   V P                   V,          P                  V4       R# R# )z
Adds an event handler function for a specific event type.

Args:
    event_type (str): Type of event to listen for ('done', 'error', or 'document')
    handler (Callable): Function to handle the event
N)r  append)r  r)  r*  s   &&&r!   add_event_listenerCrawlWatcher.add_event_listener
  s.     ,,,
+227; -r2   c                @   < V ^8  d   QhRS[ RS[S[ S[3,          RR/# )r)   r)  detailr  Nr  )r.   r/   s   "r!   r0   r  
  s*     
  
  
 d38n 
  
 r2   c                n    WP                   9   d%   V P                   V,           F  pV! V4       K  	  R# R# )z
Dispatches an event to all registered handlers for that event type.

Args:
    event_type (str): Type of event to dispatch
    detail (Dict[str, Any]): Event details/data to pass to handlers
N)r  )r  r)  r0  r*  s   &&& r!   dispatch_eventCrawlWatcher.dispatch_event
  s4     ,,,..z:: ; -r2   c                :   < V ^8  d   QhRS[ S[S[3,          RR/# r)   r$  r  Nr  )r.   r/   s   "r!   r0   r  
  '     R Rc3h RD Rr2   c                  "   VR,          R8X  d@   RV n         V P                  RRV P                   RV P                  RV P                  /4       R# VR,          R8X  dI   RV n         V P                  RRV P                   RV P                  RVR,          RV P                  /4       R# VR,          R	8X  d}   VR,          R,          V n         V P                  P	                  VR,          P                  R. 4      4       V P                   F#  pV P                  R
RVRV P                  /4       K%  	  R# VR,          R
8X  dL   V P                  P                  VR,          4       V P                  R
RVR,          RV P                  /4       R# R# 5i)zq
Handles incoming WebSocket messages based on their type.

Args:
    msg (Dict[str, Any]): The message to handle
r   r  rv   r  r  r  r   rw   catchupr  Nr  r2  r  r  r  r  r,  r  r$  docs   && r!   r"  CrawlWatcher._handle_message
  C     v;& %DK4;;		SWY]Y`Y`(ab[G#"DK(DKKT[]`ah]ikoquqxqx)yz[I%f+h/DKIIS[__VR89yy##JdDGG0LM ![J&IIS[)
VS[$,PQ '   F	F)r  r  r  r  r  r  N)r4   r5   r6   r7   r8   r  r  r  r-  r2  r"  r:   r;   r<   s   @r!   r#  r#  i
  sH     


 

	* 	*	, 	,	< 	<
  
 R Rr2   r#  c            &         a  ] tR tRt o RtR|V 3R lR lltR}V 3R lR lltR}V 3R lR	 lltV 3R
 lR ltV 3R lR lt	R~V 3R lR llt
R~V 3R lR ll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"RR#RR$R/V 3R% lR& ll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#RR$RR'^R(R/V 3R) lR* ll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#RR$RR+RR(R/V 3R, lR- lltR.RR/RR0RR1RR2RR3RR4RR5RR6RR7RR8RR9RR:RR;RR<RR=RR'^R(R/V 3R> lR? lltR.RR/RR0RR1RR2RR3RR4RR5RR6RR7RR8RR9RR:RR;RR<RR=RR'^R(R/V 3R@ lRA lltV 3RB lRC ltRV 3RD lRE lltRFRR6RRGRRHRR2RRRRIR/V 3RJ lRK lltRRLRRMRRNRR5RORPRORQROR$R/V 3RR lRS llltV 3RT lRU ltV 3RV lRW ltV 3RX lRY ltV 3RZ lR[ ltV 3R\ lR] ltRRLRRMRRNRR5RORPRORQROR$R/V 3R^ lR_ llltR`RRaRRbR/V 3Rc lRd lltR`RRaRReRRbR/V 3Rf lRg lltV 3Rh lRi ltR0RRjRR`RRkRRNRRlRRmRRnR/V 3Ro lRp lltR0RRjRR`RRkRRNRRlR/V 3Rq lRr lltV 3Rs lRt lt R2RRuRRvRRwRRxRRRRRR7RRIR/	V 3Ry lRz llt!R{t"V t#R# )AsyncFirecrawlAppi
  z
Asynchronous version of FirecrawlApp that implements async methods using aiohttp.
Provides non-blocking alternatives to all FirecrawlApp operations.
Nc                   < V ^8  d   QhRS[ RS[ RS[S[ S[ 3,          RS[S[S[ S[3,          ,          RS[RS[RS[S[ S[3,          /# )r)   methodr^   rt   r  r  r  r  )r-   r   r   r   r   r   )r.   r/   s   "r!   r0   AsyncFirecrawlApp.__annotate__
  sn     +4 +4+4 +4 #s(^	+4
 4S>*+4 +4 "+4 -1cN+4r2   c                  "   \         P                  ! 4       ;_uu_4       GRj  xL
 p\        V4       F  p VP                  WW4R7      ;_uu_4       GRj  xL
 p	V	P                  R8X  d@   \
        P                  ! V^V,          ,          4      G Rj  xL
   RRR4      GRj  xL
  Kx  V	P                  R8  d   V P                  V	RV R24      G Rj  xL
  V	P                  4       G Rj  xL
 uuRRR4      GRj  xL
  u uuRRR4      GRj  xL
  # 	  \        R4      h EL L L L LX LB L3 L!  + GRj  xL 
 '       g   i     EK  ; i  \         P                   dI   p
Y^,
          8X  d   T
h\
        P                  ! T^T,          ,          4      G Rj  xL 
   Rp
?
EKy  Rp
?
ii ; i  + GRj  xL 
 '       g   i     R# ; i5i)a  
Generic async request method with exponential backoff retry logic.

Args:
    method (str): The HTTP method to use (e.g., "GET" or "POST").
    url (str): The URL to send the request to.
    headers (Dict[str, str]): Headers to include in the request.
    data (Optional[Dict[str, Any]]): The JSON data to include in the request body (only for POST requests).
    retries (int): Maximum number of retry attempts (default: 3).
    backoff_factor (float): Factor to calculate delay between retries (default: 0.5).
        Delay will be backoff_factor * (2 ** retry_count).

Returns:
    Dict[str, Any]: The parsed JSON response from the server.

Raises:
    aiohttp.ClientError: If the request fails after all retries.
    Exception: If max retries are exceeded or other errors occur.
N)rB  r^   rt   rP   r  i,  zmake z requestzMax retries exceeded)aiohttpClientSessionr  requestr  asyncior`  r  rP   ClientErrorr   )r  rB  r^   rt   r  r  r  sessionr  r  r  s   &&&&&&&    r!   _async_request AsyncFirecrawlApp._async_request
  s{    6 ((***g >I&%  /      !#??c1")--!w,0O"PPP$      $??c1"&"4"4Xvhh?W"XXX%-]]_4      +**) 233! +  Q	  Y4  +        ** IA+-!--!w,(GHHHHI +***s?  "GD&GF5ED)E9D7D+D7E%D-
&E*F5,*D7D/D7.D1/D72E?D3 EF5GD5GF5&G)E+D7-E/D71D73E5G7E=E >
E	EEF5EF2	*6F-	 F#!F-	&F5-F2	2F55G	;F><
G	G			Gc                   < V ^8  d   QhRS[ RS[S[ S[3,          RS[S[ S[ 3,          RS[RS[RS[S[ S[3,          /# r  )r-   r   r   r   r   )r.   r/   s   "r!   r0   rC  
  s]     ^ ^^"&sCx.^;?S>^^.3^>B38n^r2   c                F   "   V P                  RWW$V4      G Rj  xL
 #  L5i)a  
Make an async POST request with exponential backoff retry logic.

Args:
    url (str): The URL to send the POST request to.
    data (Dict[str, Any]): The JSON data to include in the request body.
    headers (Dict[str, str]): Headers to include in the request.
    retries (int): Maximum number of retry attempts (default: 3).
    backoff_factor (float): Factor to calculate delay between retries (default: 0.5).
        Delay will be backoff_factor * (2 ** retry_count).

Returns:
    Dict[str, Any]: The parsed JSON response from the server.

Raises:
    aiohttp.ClientError: If the request fails after all retries.
    Exception: If max retries are exceeded or other errors occur.
POSTNrK  )r  r^   r  rt   r  r  s   &&&&&&r!   _async_post_request%AsyncFirecrawlApp._async_post_request
  s$     * ((tn]]]]   !!c                d   < V ^8  d   QhRS[ RS[S[ S[ 3,          RS[RS[RS[S[ S[3,          /# r  )r-   r   r   r   r   )r.   r/   s   "r!   r0   rC    sL     ] ]]%)#s(^]].3]>B38n]r2   c                F   "   V P                  RWRW44      G Rj  xL
 #  L5i)ac  
Make an async GET request with exponential backoff retry logic.

Args:
    url (str): The URL to send the GET request to.
    headers (Dict[str, str]): Headers to include in the request.
    retries (int): Maximum number of retry attempts (default: 3).
    backoff_factor (float): Factor to calculate delay between retries (default: 0.5).
        Delay will be backoff_factor * (2 ** retry_count).

Returns:
    Dict[str, Any]: The parsed JSON response from the server.

Raises:
    aiohttp.ClientError: If the request fails after all retries.
    Exception: If max retries are exceeded or other errors occur.
GETNrP  )r  r^   rt   r  r  s   &&&&&r!   _async_get_request$AsyncFirecrawlApp._async_get_request  s$     ( ((dG\\\\rS  c                >   < V ^8  d   QhRS[ P                  RS[RR/# r  rE  ClientResponser-   )r.   r/   s   "r!   r0   rC  $  s)     + +G,B,B +C +TX +r2   c                R  "    VP                  4       G Rj  xL
 pVP                  RR4      pVP                  RR4      pT P                  TP                  Y$T4      G Rj  xL
 p\        P                  ! T4      h Lc   \        P                  ! RTP                   24      h; i LD5i)a  
Handle errors from async API responses with detailed error messages.

Args:
    response (aiohttp.ClientResponse): The response object from the failed request
    action (str): Description of the action that was being attempted

Raises:
    aiohttp.ClientError: With a detailed error message based on the response status:
        - 402: Payment Required
        - 408: Request Timeout
        - 409: Conflict
        - 500: Internal Server Error
        - Other: Unexpected error with status code
Nr   r  r  r  ?Failed to parse Firecrawl error response as JSON. Status code: )rP   r  rE  rI  r  _get_async_error_messager  r  r  
error_datar  r  r  s   &&&    r!   r  AsyncFirecrawlApp._handle_error$  s      	{'}}.J&NN74PQM&NN96]^M 55hoov^kll!!'** /	{%%(ghphwhwgx&yzzls8   B'A= A;(A=   B' B%!B';A= =%B""B'c          
      8   < V ^8  d   QhRS[ RS[RS[RS[RS[/# r  r  )r.   r/   s   "r!   r0   rC  ?  :     Z Z# Zs Z[^ Zor Zwz Zr2   c                .   "   V P                  WW44      # 5ia  
Generate a standardized error message based on HTTP status code for async operations.

Args:
    status_code (int): The HTTP status code from the response
    action (str): Description of the action that was being performed
    error_message (str): The error message from the API response
    error_details (str): Additional error details from the API response
    
Returns:
    str: A formatted error message
r  r  s   &&&&&r!   r^  *AsyncFirecrawlApp._get_async_error_message?        &&{MYY   c                P   < V ^8  d   QhRS[ RS[S[,          RS[S[ ,          RR/# )r)   r^   r|  r  r  AsyncCrawlWatcher)r-   r   r  )r.   r/   s   "r!   r0   rC  N  s=     *9 *9*9 [)*9 &c]	*9 7J	*9r2   c                   "   V P                  WV4      G Rj  xL
 pVP                  R4      '       d   RV9   d   \        VR,          V 4      # \        R4      h L@5i)a  
Initiate an async crawl job and return an AsyncCrawlWatcher to monitor progress via WebSocket.

Args:
  url (str): Target URL to start crawling from
  params (Optional[CrawlParams]): See CrawlParams model for configuration:
    URL Discovery:
    * includePaths - Patterns of URLs to include
    * excludePaths - Patterns of URLs to exclude
    * maxDepth - Maximum crawl depth
    * maxDiscoveryDepth - Maximum depth for finding new URLs
    * limit - Maximum pages to crawl

    Link Following:
    * allowBackwardLinks - DEPRECATED: Use crawlEntireDomain instead
    * crawlEntireDomain - Follow parent directory links
    * allowExternalLinks - Follow external domain links  
    * ignoreSitemap - Skip sitemap.xml processing

    Advanced:
    * scrapeOptions - Page scraping configuration
    * webhook - Notification webhook settings
    * deduplicateSimilarURLs - Remove similar URLs
    * ignoreQueryParameters - Ignore URL parameters
    * regexOnFullURL - Apply regex to full URLs
  idempotency_key (Optional[str]): Unique key to prevent duplicate requests

Returns:
  AsyncCrawlWatcher: An instance to monitor the crawl job via WebSocket

Raises:
  Exception: If crawl job fails to start
Nr   r  r%  )r  r  rk  r   )r  r^   r|  r  r&  s   &&&& r!   r'  %AsyncFirecrawlApp.crawl_url_and_watchN  sY     L  $33CQQi((T^-C$^D%94@@788	 R   AAA&Ac                `   < V ^8  d   QhRS[ S[,          RS[S[,          RS[S[,          RR/# )r)   r4  r|  r  r  rk  )r   r-   r   r   )r.   r/   s   "r!   r0   rC  z  sG     (@ (@s)(@ \*(@ &c]	(@ 7J	(@r2   c                   "   V P                  WV4      G Rj  xL
 pVP                  R4      '       d   RV9   d   \        VR,          V 4      # \        R4      h L@5i)a  
Initiate an async batch scrape job and return an AsyncCrawlWatcher to monitor progress.

Args:
    urls (List[str]): List of URLs to scrape
    params (Optional[ScrapeParams]): See ScrapeParams model for configuration:

      Content Options:
      * formats - Content formats to retrieve
      * includeTags - HTML tags to include
      * excludeTags - HTML tags to exclude
      * onlyMainContent - Extract main content only
      
      Request Options:
      * headers - Custom HTTP headers
      * timeout - Request timeout (ms)
      * mobile - Use mobile user agent
      * proxy - Proxy type
      
      Extraction Options:
      * extract - Content extraction config
      * jsonOptions - JSON extraction config
      * actions - Actions to perform
    idempotency_key (Optional[str]): Unique key to prevent duplicate requests

Returns:
    AsyncCrawlWatcher: An instance to monitor the batch scrape job via WebSocket

Raises:
    Exception: If batch scrape job fails to start
Nr   r  rD  )r?  r  rk  r   )r  r4  r|  r  batch_responses   &&&& r!   rC  -AsyncFirecrawlApp.batch_scrape_urls_and_watchz  sY     H  $;;D/ZZi((T^-C$^D%94@@>??	 [rn  r   rt   r  r  r  r  r   r   r   r   r  r  r  r   r  rc   r  rf   r   c          /      f  < V ^8  d   QhRS[ RS[S[S[R,          ,          ,          RS[S[S[ S[ 3,          ,          RS[S[S[ ,          ,          RS[S[S[ ,          ,          RS[S[,          RS[S[,          R	S[S[,          R
S[S[,          RS[S[,          RS[S[,          RS[S[,          RS[S[,          RS[S[R,          ,          RS[S[,          RS[S[,          RS[S[,          RS[S[S[	S[
S[S[S[S[S[S[S[S[3	,          ,          ,          RS[S[,          RS[S[,          /# )r)   r^   r   rc   rt   r  r  r  r  r   r   r   r  r  r  r   r  r  rf   r   r  r   r   )r-   r   r   r   r   r   r   rl   r   r   r   r   r   r   r   r   r   r   r   r&   r   r   )r.   r/   s   "r!   r0   rC    s    HM HMHM d7  ,g  $h  i  j	HM
 d38n-HM #49-HM #49-HM  (~HM smHM c]HM ~.HM TNHM $,D>HM #+4.HM  ~HM  G$>?@!HM"  ~#HM$ j)%HM& #:.'HM( d55E{T_alnz  }I  Kb  dm  *m  $n  o  p)HM* L)+HM, (,-HMr2   c                 "   V P                  VR4       V P                  4       pRVRR\         2/pV'       d   VVR&   V'       d   VVR&   V'       d   VVR&   V'       d   VVR&   Ve   VVR
&   V'       d   VVR&   V'       d   VVR&   V	'       d   V	P                  RRR7      VR&   V
e   V
VR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   V'       d   VVR&   Ve   VVR&   Vex   V P	                  V4      p\        V\        4      '       d#   RV9   d   V P	                  VR,          4      VR&   \        V\        4      '       d   TMVP                  RRR7      VR&   Vex   V P	                  V4      p\        V\        4      '       d#   RV9   d   V P	                  VR,          4      VR&   \        V\        4      '       d   TMVP                  RRR7      VR&   V'       d?   V Uu. uF.  p\        V\        4      '       d   TMVP                  RRR7      NK0  	  upVR&   Ve   VP                  RRR7      VR&   RV9   dG   VR,          '       d8   RVR,          9   d*   V P	                  VR,          R,          4      VR,          R&   RV9   dG   VR,          '       d8   RVR,          9   d*   V P	                  VR,          R,          4      VR,          R&   RpV P                  V P                   V 2VV4      G R	j  xL
 pVP                  R4      '       d   RV9   d   \        R / VR,          B # RV9   d   \        RVR,           24      hVP                  R\        V4      4      p\        RV 24      hu upi  L~5i)!a^  
Scrape a single URL asynchronously.

Args:
  url (str): Target URL to scrape
  formats (Optional[List[Literal["markdown", "html", "rawHtml", "content", "links", "screenshot", "screenshot@fullPage", "extract", "json"]]]): Content types to retrieve (markdown/html/etc)
  headers (Optional[Dict[str, str]]): Custom HTTP headers
  include_tags (Optional[List[str]]): HTML tags to include
  exclude_tags (Optional[List[str]]): HTML tags to exclude
  only_main_content (Optional[bool]): Extract main content only
  wait_for (Optional[int]): Wait for a specific element to appear
  timeout (Optional[int]): Request timeout (ms)
  location (Optional[LocationConfig]): Location configuration
  mobile (Optional[bool]): Use mobile user agent
  skip_tls_verification (Optional[bool]): Skip TLS verification
  remove_base64_images (Optional[bool]): Remove base64 images
  block_ads (Optional[bool]): Block ads
  proxy (Optional[Literal["basic", "stealth", "auto"]]): Proxy type (basic/stealth)
  extract (Optional[JsonConfig]): Content extraction settings
  json_options (Optional[JsonConfig]): JSON extraction settings
  actions (Optional[List[Union[WaitAction, ScreenshotAction, ClickAction, WriteAction, PressAction, ScrollAction, ScrapeAction, ExecuteJavascriptAction, PDFAction]]]): Actions to perform
  agent (Optional[AgentOptions]): Agent configuration for FIRE-1 model
  **kwargs: Additional parameters to pass to the API

Returns:
    ScrapeResponse with:
    * success - Whether scrape was successful
    * markdown - Markdown content if requested
    * html - HTML content if requested
    * rawHtml - Raw HTML content if requested
    * links - Extracted links if requested
    * screenshot - Screenshot if requested
    * extract - Extracted data if requested
    * json - JSON data if requested
    * error - Error message if scrape failed

Raises:
    Exception: If scraping fails
r  r^   rH  r  r   rt   r   r   Nr   r   r   Tr  r   r   r   r   r   r   r   r}   rc   r   rf   r   r  r   r  r   r  r3   )r  r  r  r  r  r  rQ  r  r  r   r   r-   )r  r^   r   rt   r  r  r  r  r   r   r   r  r  r  r   r  rc   r  rf   r   r  r  r  r  r
  r  error_contents   &&$$$$$$$$$$$$$$$$$$,      r!   r  AsyncFirecrawlApp.scrape_url  s    ~ 	fl3((* 3G9-
 '.M)$'.M)$+7M-(+7M-((/@M+,'/M)$'.M)$(0tRV(WM*%&,M(# ,3HM/0+2FM./ (1M*%%*M'" (1M*%..w7G'4((X-@$($<$<WX=N$O!2<Wd2K2KwQXQ]Q]gkz~Q]QM)$#33LAL,--(l2J)-)A)A,xBX)YX&;ElTX;Y;Y<_k_p_pz~  NR_p  `SM-( MT  (U  MT  CI*VT2J2JPVP[P[eix|P[P}(}  MT  (UM)$%*ZZDZ%QM'"%-	*B*BxS`ajSkGk151I1I-XaJbckJl1mM)$X.M)mM.J.Jx[hiv[wOw595M5Mm\iNjksNt5uM-(2  11||nXJ'
 
 <<	""v'9!5HV$455 ;HW<M;NOPP %LL#h-@M;M?KLL/ (U
se   AM8M8M8!M87M8M8AM8DM8M8#4M15M8AM8AM87M68M8A$M8r  r  c          -      |  < V ^8  d   QhRS[ S[,          RS[S[ S[R,          ,          ,          RS[S[S[S[3,          ,          RS[S[ S[,          ,          RS[S[ S[,          ,          RS[S[,          RS[S[,          R	S[S[,          R
S[S[,          RS[S[,          RS[S[,          RS[S[,          RS[S[,          RS[S[R,          ,          RS[S[,          RS[S[,          RS[S[ S[	S[
S[S[S[S[S[S[S[S[3	,          ,          ,          RS[S[,          RS[S[,          RS[S[,          RS[/# )r)   r4  r   rc   rt   r  r  r  r  r   r   r   r  r  r  r   r  rf   r   r  r  r  r5  r   r6  )r.   r/   s   "r!   r0   rC  .  s    HC HC3iHC $w  (Q   R  S  T	HC
 $sCx.)HC tCy)HC tCy)HC $D>HC 3-HC #HC >*HC HC  (~HC 'tnHC D>HC   :;<!HC" *%#HC$ z*%HC& $uZ1A;P[]hjv  yE  G^  `i  &i   j  k  l'HC( %)HC*  }+HC, "#-HC0 
#1HCr2   c                 "   V P                  VR4       / pVe   VVR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   Ve   VVR	&   V	e   V	P                  R
R
R7      VR&   V
e   V
VR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   Vex   V P                  V4      p\        V\        4      '       d#   RV9   d   V P                  VR,          4      VR&   \        V\        4      '       d   TMVP                  R
R
R7      VR&   Vex   V P                  V4      p\        V\        4      '       d#   RV9   d   V P                  VR,          4      VR&   \        V\        4      '       d   TMVP                  R
R
R7      VR&   Ve'   V Uu. uF  pVP                  R
R
R7      NK  	  upVR&   Ve   VP                  R
R
R7      VR&   VP	                  V4       \        R/ VB pVP                  R
R
R7      pVVR&   R\         2VR&   RV9   dG   VR,          '       d8   RVR,          9   d*   V P                  VR,          R,          4      VR,          R&   RV9   dG   VR,          '       d8   RVR,          9   d*   V P                  VR,          R,          4      VR,          R&   V P                  V4      pV P                  V P                   R2VV4      G Rj  xL
 pVP                  R4      '       d.    VP                  R4      pT P                  TTT4      G Rj  xL
 # V P                  VR4       R# u upi  La   \        R4      h; i L/5i) a  
Asynchronously scrape multiple URLs and monitor until completion.

Args:
    urls (List[str]): URLs to scrape
    formats (Optional[List[Literal]]): Content formats to retrieve
    headers (Optional[Dict[str, str]]): Custom HTTP headers
    include_tags (Optional[List[str]]): HTML tags to include
    exclude_tags (Optional[List[str]]): HTML tags to exclude
    only_main_content (Optional[bool]): Extract main content only
    wait_for (Optional[int]): Wait time in milliseconds
    timeout (Optional[int]): Request timeout in milliseconds
    location (Optional[LocationConfig]): Location configuration
    mobile (Optional[bool]): Use mobile user agent
    skip_tls_verification (Optional[bool]): Skip TLS verification
    remove_base64_images (Optional[bool]): Remove base64 encoded images
    block_ads (Optional[bool]): Block advertisements
    proxy (Optional[Literal]): Proxy type to use
    extract (Optional[JsonConfig]): Content extraction config
    json_options (Optional[JsonConfig]): JSON extraction config
    actions (Optional[List[Union]]): Actions to perform
    agent (Optional[AgentOptions]): Agent configuration
    poll_interval (Optional[int]): Seconds between status checks (default: 2)
    idempotency_key (Optional[str]): Unique key to prevent duplicate requests
    **kwargs: Additional parameters to pass to the API

Returns:
    BatchScrapeStatusResponse with:
    * Scraping status and progress
    * Scraped content for each URL
    * Success/error information

Raises:
    Exception: If batch scrape fails
r8  Nr   rt   r   r   r   r   r   Tr  r   r   r   r   r   r   r}   rc   r   rf   r   r4  r  rH  r9  r   r  r  r:  r3   )r  r  r  r  r  r   r  r  rQ  r  r  r   _async_monitor_job_statusr  )r  r4  r   rt   r  r  r  r  r   r   r   r  r  r  r   rc   r  rf   r   r  r  r  r  r  r  r  r  r  s   &&$$$$$$$$$$$$$$$$$$$,      r!   r8  #AsyncFirecrawlApp.batch_scrape_urls.  s    z 	f&9: '.M)$'.M)$#+7M-(#+7M-((/@M+,'/M)$'.M)$(0tRV(WM*%&,M(# ,3HM/0+2FM./ (1M*%%*M'"..w7G'4((X-@$($<$<WX=N$O!2<Wd2K2KwQXQ]Q]gkz~Q]QM)$#33LAL,--(l2J)-)A)A,xBX)YX&;ElTX;Y;Y<_k_p_pz~  NR_p  `SM-(dk'ldkZ`TPT(Udk'lM)$%*ZZDZ%QM'" 	V$ $4m4"''D'I"F"-gY 7H#I(>(>8{[dOeCe/3/G/GT]H^_gHh/iK	"8,K'K,F,F8WbcpWqKq373K3KKXeLfgoLp3qK&x0 ''811||n,-
 
 <<	""P\\$' 77G]SSSx)ABC (m(
P"MOOSsQ   FMM7A5M-AM:A+M%M&MM	 M)M*M	MMr  c          -      |  < V ^8  d   QhRS[ S[,          RS[S[ S[R,          ,          ,          RS[S[S[S[3,          ,          RS[S[ S[,          ,          RS[S[ S[,          ,          RS[S[,          RS[S[,          R	S[S[,          R
S[S[,          RS[S[,          RS[S[,          RS[S[,          RS[S[,          RS[S[R,          ,          RS[S[,          RS[S[,          RS[S[ S[	S[
S[S[S[S[S[S[S[S[3	,          ,          ,          RS[S[,          RS[S[,          RS[S[,          RS[/# )r)   r4  r   rc   rt   r  r  r  r  r   r   r   r  r  r  r   r  rf   r   r  r  r  r5  r   r=  )r.   r/   s   "r!   r0   rC    s    JI JI3iJI $w  (Q   R  S  T	JI
 $sCx.)JI tCy)JI tCy)JI $D>JI 3-JI #JI >*JI JI  (~JI 'tnJI D>JI   :;<!JI" *%#JI$ z*%JI& $uZ1A;P[]hjv  yE  G^  `i  &i   j  k  l'JI( %)JI* &d^+JI, "#-JI0 
1JIr2   c                 "   V P                  VR4       / pVe   VVR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   Ve   VVR	&   V	e   V	P                  R
R
R7      VR&   V
e   V
VR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   Vex   V P                  V4      p\        V\        4      '       d#   RV9   d   V P                  VR,          4      VR&   \        V\        4      '       d   TMVP                  R
R
R7      VR&   Vex   V P                  V4      p\        V\        4      '       d#   RV9   d   V P                  VR,          4      VR&   \        V\        4      '       d   TMVP                  R
R
R7      VR&   V'       d?   V Uu. uF.  p\        V\        4      '       d   TMVP                  R
R
R7      NK0  	  upVR&   Ve   VP                  R
R
R7      VR&   Ve   VVR&   VP	                  V4       \        R/ VB pVP                  R
R
R7      pVVR&   R\         2VR&   RV9   dG   VR,          '       d8   RVR,          9   d*   V P                  VR,          R,          4      VR,          R&   RV9   dG   VR,          '       d8   RVR,          9   d*   V P                  VR,          R,          4      VR,          R&   V P                  V4      pV P                  V P                   R2VV4      G Rj  xL
 pVP                  R4      ^8X  d    \        R/ VP                  4       B # V P                  VR4      G Rj  xL
  R# u upi  LU   \        R4      h; i L5i) a*  
Initiate a batch scrape job asynchronously.

Args:
    urls (List[str]): URLs to scrape
    formats (Optional[List[Literal]]): Content formats to retrieve
    headers (Optional[Dict[str, str]]): Custom HTTP headers
    include_tags (Optional[List[str]]): HTML tags to include
    exclude_tags (Optional[List[str]]): HTML tags to exclude
    only_main_content (Optional[bool]): Extract main content only
    wait_for (Optional[int]): Wait time in milliseconds
    timeout (Optional[int]): Request timeout in milliseconds
    location (Optional[LocationConfig]): Location configuration
    mobile (Optional[bool]): Use mobile user agent
    skip_tls_verification (Optional[bool]): Skip TLS verification
    remove_base64_images (Optional[bool]): Remove base64 encoded images
    block_ads (Optional[bool]): Block advertisements
    proxy (Optional[Literal]): Proxy type to use
    extract (Optional[JsonConfig]): Content extraction config
    json_options (Optional[JsonConfig]): JSON extraction config
    actions (Optional[List[Union]]): Actions to perform
    agent (Optional[AgentOptions]): Agent configuration
    zero_data_retention (Optional[bool]): Whether to delete data after 24 hours
    idempotency_key (Optional[str]): Unique key to prevent duplicate requests
    **kwargs: Additional parameters to pass to the API

Returns:
    BatchScrapeResponse with:
    * success - Whether job started successfully
    * id - Unique identifier for the job
    * url - Status check URL
    * error - Error message if start failed

Raises:
    Exception: If job initiation fails
r?  Nr   rt   r   r   r   r   r   Tr  r   r   r   r   r   r   r}   rc   r   rf   r   r  r4  r  rH  r9  r  r  r:  r3   )r  r  r  r  r  r   r  r  rQ  r  r  r  rP   r   r  )r  r4  r   rt   r  r  r  r  r   r   r   r  r  r  r   rc   r  rf   r   r  r  r  r  r  r  r  r  s   &&$$$$$$$$$$$$$$$$$$$,     r!   r?  )AsyncFirecrawlApp.async_batch_scrape_urls  s    | 	f&?@ '.M)$'.M)$#+7M-(#+7M-((/@M+,'/M)$'.M)$(0tRV(WM*%&,M(# ,3HM/0+2FM./ (1M*%%*M'"..w7G'4((X-@$($<$<WX=N$O!2<Wd2K2KwQXQ]Q]gkz~Q]QM)$#33LAL,--(l2J)-)A)A,xBX)YX&;ElTX;Y;Y<_k_p_pz~  NR_p  `SM-( MT  (U  MT  CI*VT2J2JPVP[P[eix|P[P}(}  MT  (UM)$%*ZZDZ%QM'"*1DM-. 	V$ $4m4"''D'I"F"-gY 7H#I(>(>8{[dOeCe/3/G/GT]H^_gHh/iK	"8,K'K,F,F8WbcpWqKq373K3KKXeLfgoLp3qK&x0 ''811||n,-
 
 <<&#-P*=X]]_== $$X/GHHHE (U,
P"MOOHsW   FM4M44MA>M4AM4A+M4
M M4&M" >M4M2M4"M//M4r  r  r  r  r  r  r  r  r  r  r   r  r  r  r'  r  c          (        < V ^8  d   QhRS[ RS[S[S[ ,          ,          RS[S[S[ ,          ,          RS[S[,          RS[S[,          RS[S[,          RS[S[,          RS[S[,          R	S[S[,          R
S[S[,          RS[S[,          RS[S[S[ S[3,          ,          RS[S[,          RS[S[,          RS[S[,          RS[S[,          RS[S[,          RS[S[,          RS[S[ ,          RS[/# r)   r^   r  r  r  r  r  r  r  r  r  r  r   r  r  r  r'  r  r  r  r  r  )r.   r/   s   "r!   r0   rC  E  s]    uB uBuB  S	*	uB
  S	*uB C=uB &c]uB }uB 'tnuB &d^uB 'tnuB !uB !/uB %] 234uB #+4.uB  "*$!uB" $D>#uB$ }%uB& #4.'uB(  })uB* "#+uB. 
/uBr2   c               T  "   V P                  VR4       / pVe   VVR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   M	Ve   VVR	&   V	e   V	VR
&   V
e   V
VR&   Ve   VP                  RRR7      VR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   VP                  V4       \        R/ VB pVP                  RRR7      pVVR&   R\         2VR&   V P                  V4      pV P                  V P                   R2VV4      G Rj  xL
 pVP                  R4      '       d.    VP                  R4      pT P                  TTT4      G Rj  xL
 # V P                  VR4      G Rj  xL
  R#  Ld   \        R4      h; i L2 L5i)a  
Crawl a website starting from a URL.

Args:
    url (str): Target URL to start crawling from
    include_paths (Optional[List[str]]): Patterns of URLs to include
    exclude_paths (Optional[List[str]]): Patterns of URLs to exclude
    max_depth (Optional[int]): Maximum crawl depth
    max_discovery_depth (Optional[int]): Maximum depth for finding new URLs
    limit (Optional[int]): Maximum pages to crawl
    allow_backward_links (Optional[bool]): DEPRECATED: Use crawl_entire_domain instead
    crawl_entire_domain (Optional[bool]): Follow parent directory links
    allow_external_links (Optional[bool]): Follow external domain links
    ignore_sitemap (Optional[bool]): Skip sitemap.xml processing
    scrape_options (Optional[ScrapeOptions]): Page scraping configuration
    webhook (Optional[Union[str, WebhookConfig]]): Notification webhook settings
    deduplicate_similar_urls (Optional[bool]): Remove similar URLs
    ignore_query_parameters (Optional[bool]): Ignore URL parameters
    regex_on_full_url (Optional[bool]): Apply regex to full URLs
    delay (Optional[int]): Delay in seconds between scrapes
    allow_subdomains (Optional[bool]): Follow subdomains
    poll_interval (Optional[int]): Seconds between status checks (default: 2)
    idempotency_key (Optional[str]): Unique key to prevent duplicate requests
    **kwargs: Additional parameters to pass to the API

Returns:
    CrawlStatusResponse with:
    * Crawling status and progress
    * Crawled page contents
    * Success/error information

Raises:
    Exception: If crawl fails
r  Nr  r  r  r  r  r   r  r!  r"  Tr  r#  r   r$  r%  r&  r'  r)  r^   r  rH  r  r   r  r  r  r3   )r  r  r  r  r  r  rQ  r  r  r   ry  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  rt   r  r  s   &&$$$$$$$$$$$$$$$$$$,      r!   r  AsyncFirecrawlApp.crawl_urlE  s3    v 	fk2 $+8L($+8L( '0L$*0CL,-$)L!*0CL,-!-1EL-.+1EL-.%,:L)%,:,?,?\`,?,aL)&-L##/5ML12".4KL01(->L)*$)L!'.>L*+ 	F# #2\2"''D'I E"-gY 7H''811\\N)
$k7< < <<	""P\\$' 77G]SSS$$X/@AAA<P"MOOSAsH   D+F(-F.F(
F F(1F$2F(F&F(F!!F(&F(c          (        < V ^8  d   QhRS[ RS[S[S[ ,          ,          RS[S[S[ ,          ,          RS[S[,          RS[S[,          RS[S[,          RS[S[,          RS[S[,          R	S[S[,          R
S[S[,          RS[S[,          RS[S[S[ S[3,          ,          RS[S[,          RS[S[,          RS[S[,          RS[S[,          RS[S[,          RS[S[,          RS[S[ ,          RS[/# r  r  )r.   r/   s   "r!   r0   rC    s]    sB sBsB  S	*	sB
  S	*sB C=sB &c]sB }sB 'tnsB &d^sB 'tnsB !sB !/sB %] 234sB #+4.sB  "*$!sB" $D>#sB$ }%sB& #4.'sB(  })sB* "#+sB. 
/sBr2   c                 "   / pVe   VVR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   M	Ve   VVR&   V	e   V	VR	&   V
e   V
VR
&   Ve   VP                  RRR7      VR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   Ve   VVR&   VP                  V4       \        R/ VB pVP                  RRR7      pVVR&   R\         2VR&   V P	                  V4      pV P                  V P                   R2VV4      G Rj  xL
 pVP                  R4      '       d    \        R/ VB # V P                  VR4      G Rj  xL
  R#  LC   \        R4      h; i L5i)a  
Start an asynchronous crawl job.

Args:
    url (str): Target URL to start crawling from
    include_paths (Optional[List[str]]): Patterns of URLs to include
    exclude_paths (Optional[List[str]]): Patterns of URLs to exclude
    max_depth (Optional[int]): Maximum crawl depth
    max_discovery_depth (Optional[int]): Maximum depth for finding new URLs
    limit (Optional[int]): Maximum pages to crawl
    allow_backward_links (Optional[bool]): DEPRECATED: Use crawl_entire_domain instead
    crawl_entire_domain (Optional[bool]): Follow parent directory links
    allow_external_links (Optional[bool]): Follow external domain links
    ignore_sitemap (Optional[bool]): Skip sitemap.xml processing
    scrape_options (Optional[ScrapeOptions]): Page scraping configuration
    webhook (Optional[Union[str, WebhookConfig]]): Notification webhook settings
    deduplicate_similar_urls (Optional[bool]): Remove similar URLs
    ignore_query_parameters (Optional[bool]): Ignore URL parameters
    regex_on_full_url (Optional[bool]): Apply regex to full URLs
    idempotency_key (Optional[str]): Unique key to prevent duplicate requests
    **kwargs: Additional parameters to pass to the API

Returns:
    CrawlResponse with:
    * success - Whether crawl started successfully
    * id - Unique identifier for the crawl job
    * url - Status check URL for the crawl
    * error - Error message if start failed

Raises:
    Exception: If crawl initiation fails
Nr  r  r  r  r  r   r  r!  r"  Tr  r#  r   r$  r%  r&  r'  r)  r^   r  rH  r  r   r  r  r3   )r  r  r  r  r  rQ  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  rt   r  s   &&$$$$$$$$$$$$$$$$$$,     r!   r  !AsyncFirecrawlApp.async_crawl_url  s    p  $+8L($+8L( '0L$*0CL,-$)L!*0CL,-!-1EL-.+1EL-.%,:L)%,:,?,?\`,?,aL)&-L##/5ML12".4KL01(->L)*$)L!'.>L*+ 	F# #2\2"''D'I E"-gY 7H ''811\\N)
$


 
 <<	""P$0x00 $$X/@AAA
P"MOOAs6   DE3EE38
E! E3E1E3!E..E3c                &   < V ^8  d   QhRS[ RS[/# r  r  )r.   r/   s   "r!   r0   rC  2  s      @ @3 @3F @r2   c           
     \  "   V P                  4       pRV 2pV P                  V P                   V 2V4      G Rj  xL
 pVP                  R4      R8X  d   RV9   d   VR,          pRV9   d   \	        VR,          4      ^ 8X  d   MmVP                  R4      pV'       g   \
        P                  R4       M>V P                  Wb4      G Rj  xL
 pVP                  VP                  R. 4      4       TpK  WTR&   \        VP                  R4      VP                  R4      VP                  R4      VP                  R	4      VP                  R
4      VP                  R4      RV9   d   RMRR7      pRV9   d   VP                  R4      Vn	        RV9   d   VP                  R4      Vn
        V#  ELl L5i)a  
Check the status and results of an asynchronous crawl job.

Args:
    id (str): Unique identifier for the crawl job

Returns:
    CrawlStatusResponse containing:
    Status Information:
    * status - Current state (scraping/completed/failed/cancelled)
    * completed - Number of pages crawled
    * total - Total pages to crawl
    * creditsUsed - API credits consumed
    * expiresAt - Data expiration timestamp
    
    Results:
    * data - List of crawled documents
    * next - URL for next page of results (if paginated)
    * success - Whether status check succeeded
    * error - Error message if failed

Raises:
    Exception: If status check fails
r  Nr  rv   r  r  r  r  r  r  r   FT)r  r  rv   r  r  r  r   )r  rW  r  r  r  r  r   r  r0  r   r  	r  r  rt   r
  r  r  r  r  r  s	   &&       r!   r  $AsyncFirecrawlApp.check_crawl_status2  s    2 '')t$ 33||nXJ'
 

 ??8$3$"6*+;v./14*v6H#'HI&*&=&=h&P PIKK	fb 9:"+K&*F#&??8,//'*!ook2#6!ook2($3E
 k!(__W5HN[ 'OOF3HMI
 !Qs)   9F,F'A!F,*F,F*	CF,*F,c                H   < V ^8  d   QhRS[ RS[S[ S[ 3,          RS[RS[/# r  r  )r.   r/   s   "r!   r0   rC  t  s9     )_ )_# )_S#X )__b )_k~ )_r2   c                  "    V P                  V P                   RV 2V4      G Rj  xL
 pVP                  R4      R8X  d   RV9   d   VR,          pRV9   d   \        VR,          4      ^ 8X  d   MmVP                  R4      pV'       g   \        P                  R4       M>V P                  Wb4      G Rj  xL
 pVP                  VP                  R. 4      4       TpK  WTR&   \        R
/ VB # \        R4      hVP                  R4      R9   d,   \        P                  ! \        V^4      4      G Rj  xL
  EK7  \        R	VR,           24      h EL' L L!5i)a  
Monitor the status of an asynchronous job until completion.

Args:
    id (str): The ID of the job to monitor
    headers (Dict[str, str]): Headers to include in status check requests
    poll_interval (int): Seconds between status checks (default: 2)

Returns:
    CrawlStatusResponse: The job results if completed successfully

Raises:
    Exception: If the job fails or an error occurs during status checks
r  Nr  rv   r  r  r  z&Job completed but no data was returnedz#Job failed or was stopped. Status: r3   r  )rW  r  r  r  r  r   r  r0  r   rH  r`  r  )r  r  rt   r  r  r  r  r  s   &&&&    r!   ry  +AsyncFirecrawlApp._async_monitor_job_statust  s=      $ 7 7<<.
2$/! K
 x(K7[(&v.D K/{623q8!#.??6#:'"NN+LM!*.*A*A(*T$T	IMM&"$=>&/*.'.===#$LMM*.nnmmCq$9:::"EkRZF[E\ ]^^3 %U ;s;   &EEA!E*E5E6A<E2E3EEEr   r)  r*  r|  c                   < V ^8  d   QhRS[ RS[S[ ,          RS[S[,          RS[S[,          RS[S[,          RS[S[,          RS[S[,          RS[S[,          R	S[/	# )
r)   r^   r   r  r)  r*  r  r   r|  r  )r-   r   r   r   r:  rA  )r.   r/   s   "r!   r0   rC    s     HE HEHE 	HE
 !HE %TNHE tnHE }HE #HE #HE 0;HEr2   c               >  "   / p	V'       d#   V	P                  VP                  RRR7      4       Ve   W)R&   Ve   W9R&   Ve   WIR&   Ve   WYR&   Ve   WiR&   Ve   WyR	&   \        R/ V	B p
V
P                  RRR7      pWR
&   R\         2VR&   RpV P	                  V P
                   V 2VRRV P                   2/R7      G Rj  xL
 pVP                  R4      '       d   RV9   d   \        R/ VB # RV9   d   \        RVR,           24      h\        RV 24      h LW5i)a  
Asynchronously map and discover links from a URL.

Args:
  url (str): Target URL to map
  params (Optional[MapParams]): See MapParams model:
    Discovery Options:
    * search - Filter pattern for URLs
    * ignoreSitemap - Skip sitemap.xml
    * includeSubdomains - Include subdomain links
    * sitemapOnly - Only use sitemap.xml
    
    Limits:
    * limit - Max URLs to return
    * timeout - Request timeout (ms)

Returns:
  MapResponse with:
  * Discovered URLs
  * Success/error status

Raises:
  Exception: If mapping fails
Tr  Nr   r"  r<  r=  r  r   r^   r  rH  r/  r  r  r  r   rb   r   zFailed to map URL. Error: r3   )
r  r  r:  r  rQ  r  r  r  rA  r   )r  r^   r   r  r)  r*  r  r   r|  r1  r  r  r
  r  s   &&$$$$$$$     r!   r.  AsyncFirecrawlApp.map_url  se    F 
fkk4dkKL #)x %*8').@*+#(4}%"'w$+y! !.:."''D'I E"-gY 7H 11||nXJ'$~&>? 2 
 
 <<	""w(':*** 8'9J8KLMM8
CDD
s   CDDD=Dr+   r}   r  Fr  r  c                  < V ^8  d   QhRS[ S[S[,          ,          RS[ S[,          RS[ S[,          RS[ S[,          RS[ S[,          RS[ S[,          RS[ S[,          RS[ S[S[S[3,          ,          R	S[S[,          /	# rQ  rR  )r.   r/   s   "r!   r0   rC    s     WR WR49%WR SM	WR
 SMWR $C=WR #+4.WR  (~WR #4.WR DcN+WR 8Gs7KWRr2   c                 "   V P                  4       p	V'       g   V'       g   \        R4      hV'       g   V'       g   \        R4      hV'       d   V P                  V4      pRT;'       g    . RVRVRVRVRR	\        4        2/p
V'       d   W*R
&   V'       d   WJR&   V'       d   WR&   V P	                  V P
                   R2V
V	4      G Rj  xL
 pVP                  R4      '       d   VP                  R4      pV'       g   \        R4      h V P                  V P
                   RV 2V	4      G Rj  xL
 pVR,          R8X  d   \        R/ VB # VR,          R9   d    \        RVR,           RVR,           24      h\        P                  ! ^4      G Rj  xL
  K  \        RVP                  R4       24      h L L L'5i)a  
Asynchronously extract structured information from URLs.

Args:
    urls (Optional[List[str]]): URLs to extract from
    prompt (Optional[str]): Custom extraction prompt
    schema (Optional[Any]): JSON schema/Pydantic model
    system_prompt (Optional[str]): System context
    allow_external_links (Optional[bool]): Follow external links
    enable_web_search (Optional[bool]): Enable web search
    show_sources (Optional[bool]): Include source URLs
    agent (Optional[Dict[str, Any]]): Agent configuration

Returns:
  ExtractResponse with:
  * Structured data matching schema
  * Source information if requested
  * Success/error status

Raises:
  ValueError: If prompt/schema missing or extraction fails
rT  rU  r4  r!  rG  rI  r}   rH  r  r+   r   r   rV  Nr   r  rW  rX  r  rv   rY  rZ  r   r[  r3   r^  )r  r  r  r"   rQ  r  r  r   rW  rL  rH  r`  )r  r4  r+   r}   r  r  r  r  r   rt   ra  r  rb  r  s   &&$$$$$$$     r!   rc   AsyncFirecrawlApp.extract  s    D '')fBCCF@AA--f5F DJJB "60<fKM?3
 %+"+8($)!11||nK(
 
 <<	""\\$'F KLL$($;$;||nL9% 
 x(K7*9[99 *.EE#l;x3H2IS^_fSgRh$ijjmmA&&&8g9N8OPQQ1
 'si    F?F?F?F?F?,,F?F?%'F?F9F?(F?0F?1F;2A#F?F=$F?;F?=F?c                &   < V ^8  d   QhRS[ RS[/# r  rG  )r.   r/   s   "r!   r0   rC  B  s      B
 B
# B
:S B
r2   c           
     0  "   V P                  4       pRV 2pV P                  V P                   V 2V4      G Rj  xL
 pVR,          R8X  d   RV9   d   VR,          pRV9   d   \        VR,          4      ^ 8X  d   MmVP	                  R4      pV'       g   \
        P                  R4       M>V P                  Wb4      G Rj  xL
 pVP                  VP	                  R. 4      4       TpK  WTR&   \        VP	                  R4      VP	                  R4      VP	                  R4      VP	                  R	4      VP	                  R
4      VP	                  R4      R7      pRV9   d   VR,          VR&   RV9   d   VR,          VR&   RRV9   d   R/VC# R/VC#  ELV L5i)a  
Check the status of an asynchronous batch scrape job.

Args:
    id (str): The ID of the batch scrape job

Returns:
    BatchScrapeStatusResponse containing:
    Status Information:
    * status - Current state (scraping/completed/failed/cancelled)
    * completed - Number of URLs scraped
    * total - Total URLs to scrape
    * creditsUsed - API credits consumed
    * expiresAt - Data expiration timestamp
    
    Results:
    * data - List of scraped documents
    * next - URL for next page of results (if paginated)
    * success - Whether status check succeeded
    * error - Error message if failed

Raises:
    Exception: If status check fails
rI  Nr  rv   r  r  r  r  r  r  )r  r  rv   r  r  r  r   r   FT)	r  rW  r  r  r  r  r   r  r  r  s	   &&       r!   rJ  +AsyncFirecrawlApp.check_batch_scrape_statusB  s    2 '')&rd+ 33||nXJ'
 

 x K/$"6*+;v./14*v6H#'HI&*&=&=h&P PIKK	fb 9:"+K&*F#,??8,//'*!ook2#6!ook2(
 k! +G 4HW[ *62HV ; 6u

 	
<@

 	
G
 !Qs)   9FFAF*F FCFFc                &   < V ^8  d   QhRS[ RS[/# r  r  )r.   r/   s   "r!   r0   rC    s     
 
# 
:M 
r2   c                   "   V P                  4       pV P                  V P                   RV R2V4      G Rj  xL
 #  L5i)a  
Get information about errors from an asynchronous batch scrape job.

Args:
  id (str): The ID of the batch scrape job

Returns:
  CrawlErrorsResponse containing:
    errors (List[Dict[str, str]]): List of errors with fields:
      * id (str): Error ID
      * timestamp (str): When the error occurred
      * url (str): URL that caused the error
      * error (str): Error message
  * robotsBlocked (List[str]): List of URLs blocked by robots.txt

Raises:
  Exception: If error check fails
rI  r  Nr  rW  r  r  r  rt   s   && r!   rN  +AsyncFirecrawlApp.check_batch_scrape_errors  sJ     & ''),,||n-bT9
 
 	
 
   6?=?c                &   < V ^8  d   QhRS[ RS[/# r  r  )r.   r/   s   "r!   r0   rC    s     
 
3 
3F 
r2   c                   "   V P                  4       pV P                  V P                   RV R2V4      G Rj  xL
 #  L5i)a  
Get information about errors from an asynchronous crawl job.

Args:
    id (str): The ID of the crawl job

Returns:
    CrawlErrorsResponse containing:
    * errors (List[Dict[str, str]]): List of errors with fields:
        - id (str): Error ID
        - timestamp (str): When the error occurred
        - url (str): URL that caused the error
        - error (str): Error message
    * robotsBlocked (List[str]): List of URLs blocked by robots.txt

Raises:
    Exception: If error check fails
r  r  Nr  r  s   && r!   r  $AsyncFirecrawlApp.check_crawl_errors  sI     & ''),,||nJrd'2
 
 	
 
r  c                <   < V ^8  d   QhRS[ RS[S[ S[3,          /# r  r  )r.   r/   s   "r!   r0   rC    s#     - -S -T#s(^ -r2   c           
        "   V P                  4       p\        P                  ! 4       ;_uu_4       GRj  xL
 pVP                  V P                   RV 2VR7      ;_uu_4       GRj  xL
 pVP                  4       G Rj  xL
 uuRRR4      GRj  xL
  uuRRR4      GRj  xL
  #  Ls LB L, L L  + GRj  xL 
 '       g   i     M; iRRR4      GRj  xL 
  R#   + GRj  xL 
 '       g   i     R# ; i5i)r  Nr  r  )r  rE  rF  r  r  rP   )r  r  rt   rJ  r  s   &&   r!   r   AsyncFirecrawlApp.cancel_crawl  s      '')((***g~~j&Ew~WWW[c%]]_, XWW +**W, X +WWWW +*****s   2C>B(C>/C!'B*(C!+B2	?B, B2	C!B.
C!C>"B0#C>*C!,B2	.C!0C>2C8B;9
CCC!C>CC>!C;	'C*(
C;	3C;	5	C>c                6   < V ^8  d   QhRS[ RS[S[,          /# re  rf  )r.   r/   s   "r!   r0   rC    s      % %s %s7K %r2   c                   "   V P                  4       p V P                  V P                   RV 2V4      G Rj  xL
 #  L  \         d   p\	        \        T4      4      hRp?ii ; i5i)a  
Check the status of an asynchronous extraction job.

Args:
    job_id (str): The ID of the extraction job

Returns:
    ExtractResponse[Any] with:
    * success (bool): Whether request succeeded
    * data (Optional[Any]): Extracted data matching schema
    * error (Optional[str]): Error message if any
    * warning (Optional[str]): Warning message if any
    * sources (Optional[List[str]]): Source URLs if requested

Raises:
    ValueError: If status check fails
rX  Nr  rW  r  r   r  r-   )r  rb  rt   r  s   &&  r!   rh  $AsyncFirecrawlApp.get_extract_status  sl     $ '')	%00<<.VH5     	%SV$$	%1   A&$? =? A&? A#
AA##A&c                  < V ^8  d   QhRS[ S[S[,          ,          RS[ S[,          RS[ S[,          RS[ S[,          RS[ S[,          RS[ S[,          RS[ S[,          RS[ S[S[S[3,          ,          R	S[S[,          /	# rQ  rR  )r.   r/   s   "r!   r0   rC    s     D% D%49%D% SM	D%
 SMD% $C=D% #+4.D%  (~D% #4.D% DcN+D% 8Gs7KD%r2   c          	       "   V P                  4       p	V'       g   V'       g   \        R4      hV'       g   V'       g   \        R4      hV'       d   V P                  V4      p\        T;'       g    . VVVVR\         2R7      p
V'       d   W*R&   V'       d   WJR&   V'       d   WR&    V P                  V P                   R2V
V	4      G R	j  xL
 #  L  \         d   p\        \        T4      4      hR	p?ii ; i5i)
aT  
Initiate an asynchronous extraction job without waiting for completion.

Args:
    urls (Optional[List[str]]): URLs to extract from
    prompt (Optional[str]): Custom extraction prompt
    schema (Optional[Any]): JSON schema/Pydantic model
    system_prompt (Optional[str]): System context
    allow_external_links (Optional[bool]): Follow external links
    enable_web_search (Optional[bool]): Enable web search
    show_sources (Optional[bool]): Include source URLs
    agent (Optional[Dict[str, Any]]): Agent configuration
    idempotency_key (Optional[str]): Unique key to prevent duplicate requests

Returns:
    ExtractResponse[Any] with:
    * success (bool): Whether request succeeded
    * data (Optional[Any]): Extracted data matching schema
    * error (Optional[str]): Error message if any

Raises:
    ValueError: If job initiation fails
rT  rU  r  )r4  r!  rG  rI  r}   rH  r+   r   r   rV  N)	r  r  r  rL  r  rQ  r  r   r-   )r  r4  r+   r}   r  r  r  r  r   rt   ra  r  s   &&$$$$$$$   r!   rl  AsyncFirecrawlApp.async_extract  s     D '')fBCCF@AA--f5F&3-$ 	*
 %+"+8($)!	%11<<.,   
  	%SV$$	%sh    C:C:C:C:C:0C:C:C:$C:)#C CC C:C C7C22C77C:rn  ro  rp  c          
      h   < V ^8  d   QhRS[ RS[S[,          RS[S[,          RS[S[,          RS[/# )r)   r^   rn  ro  rp  r  rs  )r.   r/   s   "r!   r0   rC  -  sQ     ;v ;v;v sm	;v
 %TN;v "*$;v <Z;vr2   c                 "   / pVe   W%R&   Ve   W5R&   Ve   WER&   V P                  VVVVR7      G Rj  xL
 pVP                  R4      '       d   RV9  d   V# VR,          p V P                  V4      G Rj  xL
 pVR,          R	8X  d   V# VR,          R
8X  d   \        RVP                  R4       24      hVR,          R8w  d   M \        P
                  ! ^4      G Rj  xL
  K  \        RRR7      #  L L} L5i)au  
Generate LLMs.txt for a given URL and monitor until completion.

Args:
    url (str): Target URL to generate LLMs.txt from
    max_urls (Optional[int]): Maximum URLs to process (default: 10)
    show_full_text (Optional[bool]): Include full text in output (default: False)
    experimental_stream (Optional[bool]): Enable experimental streaming

Returns:
    GenerateLLMsTextStatusResponse containing:
    * success (bool): Whether generation completed successfully
    * status (str): Status of generation (processing/completed/failed)
    * data (Dict[str, str], optional): Generated text with fields:
        - llmstxt (str): Generated LLMs.txt content
        - llmsfulltxt (str, optional): Full version if requested
    * error (str, optional): Error message if generation failed
    * expiresAt (str): When the generated data expires

Raises:
    Exception: If generation fails
Nre  rf  rv  )rn  ro  rp  r   r  r  rv   rw   z#LLMs.txt generation failed. Error: r   rP  Fry  r]  )rz  r  r{  r   rH  r`  r  )	r  r^   rn  ro  rp  r|  r  rb  r  s	   &&$$$    r!   r}  $AsyncFirecrawlApp.generate_llms_text-  s    :  (9%%3>"*.A*+66) 3	 7 
 
 ||I&&$h*>O$??GGFh;.!X-"EfjjQXFYEZ [\\!\1--"""-eCtuu-
 H #s:   3C:C4C:'C:8C69A'C: C8!C:6C:8C:rg  c                ~   < V ^8  d   QhRS[ RS[S[,          RS[S[,          RS[S[,          RS[S[,          RS[/# rr  r  )r.   r/   s   "r!   r0   rC  j  sX     5% 5%5% sm	5%
 %TN5% D>5% "*$5% <T5%r2   c               f  "   / pVe   W&R&   Ve   W6R&   Ve   WVR&   \        VVVVR7      pV P                  4       pRV/VP                  RRR7      CpR	\         2VR
&    V P	                  V P
                   R2VV4      G Rj  xL
 #  L  \         d   p	\        \        T	4      4      hRp	?	ii ; i5i)a  
Initiate an asynchronous LLMs.txt generation job without waiting for completion.

Args:
    url (str): Target URL to generate LLMs.txt from
    max_urls (Optional[int]): Maximum URLs to process (default: 10)
    show_full_text (Optional[bool]): Include full text in output (default: False)
    cache (Optional[bool]): Whether to use cached content if available (default: True)
    experimental_stream (Optional[bool]): Enable experimental streaming

Returns:
    GenerateLLMsTextResponse containing:
    * success (bool): Whether job started successfully
    * id (str): Unique identifier for the job
    * error (str, optional): Error message if start failed

Raises:
    ValueError: If job initiation fails
Nre  rf  rv  ru  r^   Tr  r  rH  r  )	rc  r  r  r  rQ  r  r   r  r-   )
r  r^   rn  ro  rg  rp  r|  rt   r  r  s
   &&$$$$    r!   rz  *AsyncFirecrawlApp.async_generate_llms_textj  s     6  (9%%3>"*.A*+''"5	
 '')CQ6;;4;#PQ	 +G95	(	%11<<.,   
  	%SV$$	%s<   AB1 #B
 BB
 B1B
 
B.B))B..B1c                &   < V ^8  d   QhRS[ RS[/# r  r  )r.   r/   s   "r!   r0   rC    s     % % %@^ %r2   c                   "   V P                  4       p V P                  V P                   RV 2V4      G Rj  xL
 #  L  \         d   p\	        \        T4      4      hRp?ii ; i5i)a  
Check the status of an asynchronous LLMs.txt generation job.

Args:
    id (str): The ID of the generation job

Returns:
    GenerateLLMsTextStatusResponse containing:
    * success (bool): Whether generation completed successfully
    * status (str): Status of generation (processing/completed/failed)
    * data (Dict[str, str], optional): Generated text with fields:
        - llmstxt (str): Generated LLMs.txt content
        - llmsfulltxt (str, optional): Full version if requested
    * error (str, optional): Error message if generation failed
    * expiresAt (str): When the generated data expires

Raises:
    ValueError: If status check fails
r  Nr  r  r  rt   r  s   &&  r!   r{  1AsyncFirecrawlApp.check_generate_llms_text_status  sl     ( '')	%00<<.RD1     	%SV$$	%r  r  r  -_AsyncFirecrawlApp__experimental_stream_stepsr  r  c                .  < V ^8  d   QhRS[ RS[S[,          RS[S[,          RS[S[,          RS[S[ ,          RS[S[ ,          RS[S[,          RS[S[S[S[ S[3,          .R	3,          ,          R
S[S[S[S[ S[3,          .R	3,          ,          RS[/
# )r)   rX  r  r  rn  r  r  r  r  Nr  r  r  )r.   r/   s   "r!   r0   rC    s     ^l ^l^l  }	^l
 !^l sm^l &c]^l $C=^l *2$^l "(DcN+;T+A"BC^l  $sCx.)94)? @A^l Nh^lr2   c          	     F  "   / p
Ve   W*R&   Ve   W:R&   Ve   WJR&   Ve   WZR&   Ve   WjR&   Ve   WzR&   \        R/ V
B p
V P                  VVVVVVR7      G Rj  xL
 pVP                  R	4      '       d   R
V9  d   V# VR
,          p^ p^ p V P                  V4      G Rj  xL
 pV'       d7   RV9   d0   VR,          VR pV F  pV! V4       K  	  \	        VR,          4      pV	'       d7   RV9   d0   VR,          VR pV F  pV	! V4       K  	  \	        VR,          4      pVR,          R8X  d   V# VR,          R8X  d   \        RVP                  R4       24      hVR,          R8w  d   M!\        P                  ! ^4      G Rj  xL
  EK  \        RRR7      #  EL@ L L5i)r  Nr  rm  re  rn  r   r  r  r   r  r{  rN  r  rv   rw   r  r   rP  Fr  r]  r3   )	rk  r  r  r  r  r   rH  r`  rx  )r  rX  r  r  rn  r  r  r  r  r  r  r  rb  r  r  r  r  r  r  r  s   &&$$$$$$$$          r!   r  AsyncFirecrawlApp.deep_research  s    P  *3J'!+5K()1I&&0?,-$.;N+&2<W89,??11!+' 2 
 
 ||I&&$h*>O$::6BBF|v5!'!56I6J!K .H) !/&)&*>&?#Y&0$Y/0A0BC)Ff% *$'y(9$:!h;.!X-"?

7@S?T UVV!\1--""")%?jkkO
  C* #sI   AF!FF!6+F!!F"F!.=F!,BF!FF!F!F!c                   < V ^8  d   QhRS[ RS[S[,          RS[S[,          RS[S[,          RS[S[ ,          RS[S[ ,          RS[S[,          RS[S[ S[3,          /# )	r)   rX  r  r  rn  r  r  r  r  r  )r.   r/   s   "r!   r0   rC    s}     :% :%:%  }	:%
 !:% sm:% &c]:% $C=:% *2$:% DHS>:%r2   c                 "   / pVe   W(R&   Ve   W8R&   Ve   WHR&   Ve   WXR&   Ve   WhR&   Ve   WxR&   \        R/ VB pV P                  4       p	RV/VP                  R	R	R
7      Cp
R\         2V
R&    V P	                  V P
                   R2V
V	4      G Rj  xL
 #  L  \         d   p\        \        T4      4      hRp?ii ; i5i)r  Nr  rm  re  rn  r   r  rX  Tr  r  rH  r  r3   )	rk  r  r  r  rQ  r  r   r  r-   )r  rX  r  r  rn  r  r  r  r  rt   r  r  s   &&$$$$$$    r!   r  %AsyncFirecrawlApp.async_deep_research  s    >  *3J'!+5K()1I&&0?,-$.;N+&2<W89,??'')e^';';TX\';']^	 +G95	(	%11<<. 12   
  	%SV$$	%s<   A1C4#B BB CB C)B==CCc                &   < V ^8  d   QhRS[ RS[/# r  r  )r.   r/   s   "r!   r0   rC  Z  s      %  %3  %;U  %r2   c                   "   V P                  4       p V P                  V P                   RV 2V4      G Rj  xL
 #  L  \         d   p\	        \        T4      4      hRp?ii ; i5i)r  r  Nr  r  s   &&  r!   r  ,AsyncFirecrawlApp.check_deep_research_statusZ  sm     2 '')	%00<<. 22$7     	%SV$$	%r  rY  rZ  r[  rn   c                  < V ^8  d   QhRS[ RS[S[,          RS[S[ ,          RS[S[ ,          RS[S[ ,          RS[S[ ,          RS[S[ ,          RS[S[,          R	S[S[,          R
S[S[S[S[ S[3,          S[3,          ,          RS[/# )r)   rX  r  rY  rZ  r[  rn   r   r   r  r|  r  )	r-   r   r   r   r   r   r   rS  r^  )r.   r/   s   "r!   r0   rC  |  s     N
 N
N
 C=	N

 #N
 SMN
 3-N
 c]N
 smN
 c]N
 %]3N
 U4S><#?@AN
 (N
r2   c       	        B  "   / pV
'       dK   \        V
\        4      '       d   VP                  V
4       M"VP                  V
P                  RRR7      4       Ve   W,R&   Ve   W<R&   Ve   WLR&   Ve   W\R&   Ve   WlR&   Ve   W|R	&   Ve   WR
&   V	e   V	P                  RRR7      VR&   VP                  V4       \        RRV/VB pVP                  RRR7      pR\         2VR&   V P                  V P                   R2VRRV P                   2/4      G Rj  xL
 #  L5i)a  
Asynchronously search for content using Firecrawl.

Args:
    query (str): Search query string
    limit (Optional[int]): Max results (default: 5)
    tbs (Optional[str]): Time filter (e.g. "qdr:d")
    filter (Optional[str]): Custom result filter
    lang (Optional[str]): Language code (default: "en")
    country (Optional[str]): Country code (default: "us") 
    location (Optional[str]): Geo-targeting
    timeout (Optional[int]): Request timeout in milliseconds
    scrape_options (Optional[ScrapeOptions]): Result scraping configuration
    params (Optional[Union[Dict[str, Any], SearchParams]]): Additional search parameters
    **kwargs: Additional keyword arguments for future compatibility

Returns:
    SearchResponse: Response containing:
        * success (bool): Whether request succeeded
        * data (List[FirecrawlDocument]): Search results
        * warning (Optional[str]): Warning message if any
        * error (Optional[str]): Error message if any

Raises:
    Exception: If search fails or response cannot be parsed
Tr  Nr  rY  rZ  r[  rn   r   r   r#  rX  r  rH  r  r  r  r3   )r  r  r  rS  r  rQ  r  r  )r  rX  r  rY  rZ  r[  rn   r   r   r  r|  r  r  r  r  s   &&$$$$$$$$$,   r!   r   AsyncFirecrawlApp.search|  sU    R &$''$$V,$$V[[$T[%RS %*'"?#&% &,(#$(&!'.)$(0*%'.)$%-;-@-@$]a-@-bM/* 	V$ $A%A=A"''D'I"-gY 7H--||nJ'~67
 
 	
 
s   DDDDr3   )Nr  r  r   r  )r)   r  )$r4   r5   r6   r7   r8   rK  rQ  rW  r  r^  r'  rC  r  r8  r?  r  r  r  ry  r.  rc   rJ  rN  r  r   rh  rl  r}  rz  r{  r  r  r  r   r:   r;   r<   s   @r!   r@  r@  
  s    
+4 +4Z^ ^.] ],+ +6Z Z*9 *9X(@ (@THM mq	HM
 15HM 15HM 15HM 15HM '+HM &+HM 26HM &*HM 59HM 48HM )-HM  DH!HM" )-#HM$ -1%HM& 26'HM( sw)HM* -1+HM HMTHC W[	HC
 -1HC -1HC -1HC -1HC #'HC "'HC .2HC "&HC 15HC 04HC %)HC  @D!HC" )-#HC$ .2%HC& os'HC( )-)HC* ()+HC, *.-HC HCVJI W[	JI
 -1JI -1JI -1JI -1JI #'JI "'JI .2JI "&JI 15JI 04JI %)JI  @D!JI" )-#JI$ .2%JI& os'JI( )-)JI* /3+JI, *.-JI JIXuB .2	uB
 .2uB $(uB .2uB  $uB 04uB /3uB 04uB *.uB 37uB 8<uB 48uB  37!uB" -1#uB$  $%uB& ,0'uB( ())uB* *.+uB uBpsB .2	sB
 .2sB $(sB .2sB  $sB 04sB /3sB 04sB *.sB 37sB 8<sB 48sB  37!sB" -1#sB$  $%sB& ,0'sB( ())sB* *.+sB sBj@ @D)_ )_VHE !%	HE
 *.HE .2HE (,HE  $HE "'HE '+HE HETWR %)	WR
 %)WR ,0WR 49WR 16WR ,1WR /3WR WRrB
 B
H
 
2
 
2- -(% %6D% %)	D%
 %)D% ,0D% 49D% 16D% ,1D% /3D% D%L;v '+	;v
 .2;v 37;v ;vz5% '+	5%
 .25% %)5% 375% 5%n% %:^l (,	^l
 )-^l '+^l .2^l ,0^l ;?^l GK^l EI^l ^l@:% (,	:%
 )-:% '+:% .2:% ,0:% ;?:% :%x %  %DN
 $(	N

 "&N
 %)N
 #'N
 &*N
 '+N
 &+N
 7;N
 EIN
 N
 N
r2   r@  c                      a a ] tR tRt oRtV3R lV 3R lltV3R lR ltV3R lR ltV3R	 lR
 ltV3R lR lt	V3R lR lt
RtVtV ;t# )rk  i  zG
Async version of CrawlWatcher that properly handles async operations.
c                &   < V ^8  d   QhRS[ RS[/# r  )r-   r@  )r.   r/   s   "r!   r0   AsyncCrawlWatcher.__annotate__  s     " "3 "%6 "r2   c                &   < \         SV `  W4       R # r  )superr  )r  r  r  	__class__s   &&&r!   r  AsyncCrawlWatcher.__init__  s    !r2   c                   < V ^8  d   QhRR/# r  r3   )r.   r/   s   "r!   r0   r    s     * *t *r2   c                @  "   \         P                  ! V P                  RRV P                  P                   23.R7      ;_uu_4       GRj  xL
 pV P                  V4      G Rj  xL
  RRR4      GRj  xL
  R#  L/ L L
  + GRj  xL 
 '       g   i     R# ; i5i)zK
Establishes async WebSocket connection and starts listening for messages.
r  r  )r  Nr  r  s   & r!   r  AsyncCrawlWatcher.connect  s      %%KK!0GDHH<L<L;M2N OP
 
 
 ,,y)))	
 
 
 *	
 
 
 
s`   A	BA;BB$A=%B)B4A?5B=B?BB	B

B	B		Bc                   < V ^8  d   QhRR/# r  r3   )r.   r/   s   "r!   r0   r    r  r2   c                   "   V  Rj  xL
  p\         P                  ! V4      pV P                  V4      G Rj  xL
  K;   L6 LD9R# 5i)z
Listens for incoming WebSocket messages and handles them asynchronously.

Args:
    websocket: The WebSocket connection object
Nr   r#  s   &&  r!   r  AsyncCrawlWatcher._listen  r&  r'  c                :   < V ^8  d   QhRS[ S[S[3,          RR/# r5  r  )r.   r/   s   "r!   r0   r    r6  r2   c                  "   VR,          R8X  d@   RV n         V P                  RRV P                   RV P                  RV P                  /4       R# VR,          R8X  dI   RV n         V P                  RRV P                   RV P                  RVR,          RV P                  /4       R# VR,          R	8X  d}   VR,          R,          V n         V P                  P	                  VR,          P                  R. 4      4       V P                   F#  pV P                  R
RVRV P                  /4       K%  	  R# VR,          R
8X  dL   V P                  P                  VR,          4       V P                  R
RVR,          RV P                  /4       R# R# 5i)z
Handles incoming WebSocket messages based on their type asynchronously.

Args:
    msg (Dict[str, Any]): The message to handle
r   r  rv   r  r  r  r   rw   r8  r  Nr9  r:  s   && r!   r"  !AsyncCrawlWatcher._handle_message  r=  r>  c                >   < V ^8  d   QhRS[ P                  RS[RR/# r  rZ  )r.   r/   s   "r!   r0   r    s)     + +G,B,B +C +TX +r2   c                f  "    VP                  4       G Rj  xL
 pVP                  RR4      pVP                  RR4      pT P
                  P                  TP                  Y$T4      G Rj  xL
 p\        P                  ! T4      h Lm   \        P                  ! RTP                   24      h; i LD5i)z)
Handle errors from async API responses.
Nr   r  r  r  r]  )rP   r  rE  rI  r  r  r^  r_  s   &&&    r!   r  AsyncCrawlWatcher._handle_error  s     	{'}}.J&NN74PQM&NN96]^M
 99(//6bopp!!'** /	{%%(ghphwhwgx&yzz qs8   B1B B(B  *B1*B/+B1B %B,,B1c          
      8   < V ^8  d   QhRS[ RS[RS[RS[RS[/# r  r  )r.   r/   s   "r!   r0   r    rc  r2   c                .   "   V P                  WW44      # 5ire  rf  r  s   &&&&&r!   r^  *AsyncCrawlWatcher._get_async_error_message  rh  ri  )r  )r4   r5   r6   r7   r8   r  r  r  r"  r  r^  r:   r;   __classcell__)r  r/   s   @@r!   rk  rk    sP     " "* *	, 	,R R,+ + Z Z Zr2   rk  c                T    V ^8  d   Qh/ ^ \         9   d   \        P                  ;R&   # )r)   r  )__conditional_annotations__loggingLogger)r.   s   "r!   r0   r0      s$     
 
R 9 8 8S
r2   )Mr  r8   r  r   r_  typingr   r   r   r   r   r   r   r	   r
   rP   r   r   warningsr  rZ   r  rE  rH  r   r"   r  	getLoggerr  r$   	BaseModelr&   r>   rH   rO   r\   rl   rr   r|   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r,  r0  r4  r:  rA  rE  rL  rS  r^  rc  rk  rr  rx  r  r  r  r  r#  r@  rk  r0   )r  s   @r!   <module>r     s  
  	  X X X   	       
 -!++K8 8CLJ!8%% !
((,, (H&& 
C++ C8**GAJ 8 *X'' *
UH&& UH.. $H&& $(### #"x)) "($$ 
($$ 
($$ 
#8%% #8%% h00 
""" "(8%% ()## ),= , &q)71:  ,(,, ,	" 2 2 	"+($$ +( H&&  	"(,, 	"(,, 
$"" $ ($$  
2H&& 
2	-h(('!* 	-
28%% 
2 X''  1X// 1	6++ 	6 8--  !3!3  x11  &);); &X%7%7  X''  +H&& +q" q"fEYR YRvF
 F
P8OZ OZr2   