
    i                         d Z ddlZddl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 ddlmZ ej                   rddlmZ d	dd
d
ddZd	ZdgZdZdZdZdddddZdededeeef   defdZdeddfdZdddefdZy)zGMX (general)

It's unclear which index it uses, the results were the most similar to Google's.

In theory it supports multiple languages, but even if changing the region on their website,
most of the results are still in English.    N)	urlencode)EngineResults)SXNG_Response)extrgen_useragenthtml_to_text)get)OnlineParamszhttps://search.gmx.comFJSON)websiteofficial_api_documentationuse_official_apirequire_api_keyresultsgeneralTdwmy)dayweekmonthyearquerypageheadersreturnc                 b    t        t         d|  d| |      }t        |j                  dd      S )Nz/web/result?q=z&page=)r   z&h=z&t=)r	   base_urlr   text)r   r   r   resps       "/root/searxng/searx/engines/gmx.py_get_page_hashr#   (   s4    (>%tf=wOD 		5%((    paramsr
   c                 L   t               dddt        d}t        t        j                         dz        }t	        | |d   |      }d| |d   ||d}|d	   rd
|d<   |j                  d      rt        |d      |d<   t         dt        |       |d<   |d   j                  |       y )Nz?text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8zen-US,en;q=0.9z
keep-alive)z
User-AgentAcceptzAccept-Language
ConnectionReferer
   pagenoen)langqr   ht
safesearchTfamily
time_rangetimez/desk?urlr   )	r   r   intr4   r#   r	   time_range_mapr   update)r   r%   r   now	page_hashargss         r"   requestr<   0   s     $oS+"G diikB
C ufX&6@I ufX.>YUXYDlXzz,%f\&:;Vjy&78F5M
9W%r$   r!   r   c                 p   t               }| j                         d   }|j                  dg       D ]1  }|j                  |j                  j                  d|d   i             3 |d   D ]J  }|j                  |j                  j                  |d   t        |d         t        |d                      L |S )	Nr   rs
suggestionr0   hitsus)r5   titlecontent)r   jsonr	   addtypesLegacyResult
MainResultr   )r!   resr   r?   results        r"   responserL   N   s    
/Ciik)$Gkk$+ I
		&&jo'FGHI &/ 
II  3K"6#;/$VC[1 ! 	

 Jr$   ) __doc__r4   typingr0   urllib.parser   searx.result_typesr   searx.extended_typesr   searx.utilsr   r   r   searx.networkr	   TYPE_CHECKINGsearx.search.processorsr
   aboutr   
categoriespagingr1   time_range_supportr7   strr6   dictr#   r<   rL    r$   r"   <module>r]      s   -   " , . 9 9 ??4 ("&	 $[
	
 cCE)# )S )4S> )c )&3 & &<? } r$   