
    i                         d Z ddlmZ ddlmZ ddlmZ ddlmZmZm	Z	m
Z
 ddlmZ ddd	d	d
dZddgZdZdZdZdZdZdZd ZdefdZy)z&Ollama model search engine for searxng    )	urlencode)datetime)html)eval_xpath_listeval_xpath_getindex
eval_xpathextract_text)EngineResultszhttps://ollama.com
Q124636097FHTML)websitewikidata_iduse_official_apirequire_api_keyresultsitreposz//li[@x-test-model]z-.//span[@x-test-search-response-title]/text()zC.//p[@class="max-w-lg break-words text-neutral-800 text-md"]/text()z	./a/@hrefz5.//span[contains(@class, "flex items-center")]/@titlec                 <    d| i}t          dt        |       |d<   |S )Nqz/search?url)base_urlr   )queryparamsquery_paramss      %/root/searxng/searx/engines/ollama.pyrequestr      s*    <Lj<)@(ABF5MM    returnc                    t               }t        j                  | j                        }t	        |t
              D ]  }d }	 t        j                  t        t        |t                    d      }|j                  |j                  j                  t        t        |t                    t        t        |t                     t"         t%        |t&        d       |              |S # t        $ r Y w xY w)Nz%b %d, %Y %I:%M %p %Zr   )titlecontentr   publishedDate)r
   r   
fromstringtextr   results_xpathr   strptimer	   r   publish_date_xpath
ValueErroraddtypes
MainResulttitle_xpathcontent_xpathr   r   	url_xpath)respresdomitempublished_dates        r   responser4   %   s    
/C
//$))
$C]3 
	%..Z.@ABD[N 	II  ":dK#@A$Zm%DEj!4T9a!H IJ,	 ! 	

$ J  		s    -C$$	C0/C0N)__doc__urllib.parser   r   lxmlr   searx.utilsr   r   r   r	   searx.result_typesr
   about
categoriesr   r%   r,   r-   r.   r'   r   r4    r   r   <module>r=      sm    , "   V V , $	 G_
%=U	L m r   