
    Mg                     l    S SK r S SKrS SKJr  S SKJrJr  \" SS9\" S5       " S S5      5       5       rg)	    N)Fore)pluginrequireT)networkgooglec                   *    \ rS rSrSrS rS rS rSrg)Scraper   a  
Runs a basic search and returns the default answer provided by google.
Google's default answers all have a class contaning BNeawe, s3v9rd, or
orAP7Wnd, so we can just run a google query and parse the results

example: google What is the Large Hadron Collider?
c                 b    UR                  U R                  U5      [        R                  5        g )N)saysearchr   BLUE)selfjarvisss      </Users/admin/workspace/ai/Jarvis/jarviscli/plugins/google.py__call__Scraper.__call__   s    

4;;q>499-    c                    SR                  UR                  S5      5      nSU S3n[        R                  " U5      n[        R
                  " UR                  S5      nUR                  SSS05      nU H1  nUR                  (       d  M  U R                  UR                  5      s  $    UR                  SSS	05      nU H1  nUR                  (       d  M  U R                  UR                  5      s  $    UR                  S5      n	/ S
Qn
U	 H0  nU
 H'  nX;   d  M
  U R                  UR                  5      s  s  $    M2     g)N+ z https://www.google.com/search?q=z&ie=utf-8&oe=utf-8zhtml.parserdivclasszBNeawe iBp4i AP7WndzBNeawe s3v9rd AP7Wnd)BNeawes3v9rdAP7WndiBp4izNo Answers Found)	joinsplitrequestsgetbs4BeautifulSouptextfind_allparse_result)r   questionqueryurlresponsesoupgoogle_answersanswerfirst_answersall_divgoogle_answer_keysr   keys                r   r   Scraper.search   s   ,-07IJ<<$  >uw8M.NO$F{{{((55 % eg7M-NO#F{{{((55 $ --&DC):,,SXX66 * 
 "r   c                     UR                  S5      S   nUR                  S5      (       a  US UR                  S5       nUS-  nU$ )N
r   	Wikipedia)r    endswithfind)r   results     r   r'   Scraper.parse_result/   sH    d#A&??;''5V[[56F$r    N)	__name__
__module____qualname____firstlineno____doc__r   r   r'   __static_attributes__r;   r   r   r	   r	      s    ."4r   r	   )r!   r#   coloramar   r   r   r	   r;   r   r   <module>rC      s<     
  " 	, ,  ,r   