
    dh>                        S SK Jr  S SKrS SKJrJrJrJr  S SKJ	r	J
r
  S SKJrJrJr  S SKJr  S SKJrJr  \(       a    " S S	\5      r " S
 S\5      rg)    )annotationsN)TYPE_CHECKINGAnyOptionalType)AsyncCallbackManagerForToolRunCallbackManagerForToolRun)	BaseModelFieldmodel_validator)BaseBrowserTool)aget_current_pageget_current_pagec                  2    \ rS rSr% Sr\" SSS9rS\S'   Srg	)
ExtractHyperlinksToolInput   z Input for ExtractHyperlinksTool.Fz-Return absolute URLs instead of relative URLs)defaultdescriptionboolabsolute_urls N)	__name__
__module____qualname____firstlineno____doc__r   r   __annotations____static_attributes__r       o/var/www/html/shao/venv/lib/python3.13/site-packages/langchain_community/tools/playwright/extract_hyperlinks.pyr   r      s    *CM4 r   r   c                      \ rS rSr% SrSrS\S'   SrS\S'   \r	S\S	'   \
" S
S9\SS j5       5       r\SS j5       r  S     SS jjr  S     SS jjrSrg)ExtractHyperlinksTool   z#Extract all hyperlinks on the page.extract_hyperlinksstrnamez-Extract all hyperlinks on the current webpager   zType[BaseModel]args_schemabefore)modec                F     SSK Jn  U$ ! [         a    [        S5      ef = f)z#Check that the arguments are valid.r   BeautifulSoupzoThe 'beautifulsoup4' package is required to use this tool. Please install it with 'pip install beautifulsoup4'.)bs4r,   ImportError)clsvaluesr,   s      r    check_bs_import%ExtractHyperlinksTool.check_bs_import&   s5    	)   	H 	s   
  c           
     f   SSK Jn  SSKJn  U" US5      nUR	                  S5      nU(       a3  U R
                  nU Vs/ sH  o" XxR                  SS5      5      PM     n	nO U Vs/ sH  oR                  SS5      PM     n	n[        R                  " [        [        U	5      5      5      $ s  snf s  snf )Nr   )urljoinr+   lxmlahref )urllib.parser4   r-   r,   find_allurlgetjsondumpslistset)
pagehtml_contentr   r4   r,   soupanchorsbase_urlanchorlinkss
             r    scrape_page!ExtractHyperlinksTool.scrape_page3   s    (% \62 --$xxHMTUW6WXzz&"'=>WEUE:AB'ZZ+'EB zz$s5z*++ VBs    B)%B.Nc                    U R                   c  [        SU R                   35      e[        U R                   5      nUR	                  5       nU R                  X4U5      $ )zUse the tool.z$Synchronous browser not provided to )sync_browser
ValueErrorr&   r   contentrH   selfr   run_managerrA   rB   s        r    _runExtractHyperlinksTool._runG   sU     $CDII;OPP 1 12||~MBBr   c                   #    U R                   c  [        SU R                   35      e[        U R                   5      I Sh  vN nUR	                  5       I Sh  vN nU R                  X4U5      $  N. N7f)zUse the tool asynchronously.Nz%Asynchronous browser not provided to )async_browserrL   r&   r   rM   rH   rN   s        r    _arunExtractHyperlinksTool._arunS   sf      %DTYYKPQQ&t'9'9::!\\^+MBB ;+s#   >A3 A/A3A1A31A3r   )r0   dictreturnr   )rA   r   rB   r%   r   r   rX   r%   )FN)r   r   rP   z#Optional[CallbackManagerForToolRun]rX   r%   )r   r   rP   z(Optional[AsyncCallbackManagerForToolRun]rX   r%   )r   r   r   r   r   r&   r   r   r   r'   r   classmethodr1   staticmethodrH   rQ   rU   r   r   r   r    r"   r"      s    -$D#$FKF#=K=(#	  $	 , ,* $;?
C
C 9
C 
	
C $@D
C
C >
C 
	
C 
Cr   r"   )
__future__r   r=   typingr   r   r   r   langchain_core.callbacksr   r	   pydanticr
   r   r   )langchain_community.tools.playwright.baser   *langchain_community.tools.playwright.utilsr   r   r   r"   r   r   r    <module>ra      sH    "  5 5 7 6 E
  >CO >Cr   