
    gv                         d dl mZ d dlmZ d dlmZ  G d de      Z e       Zej                  Zej                  Z	ej                  Z
ej                  Zy)   )
HTTPClient)SearchIDNotProvided)SerpResultsc                   R    e Zd ZdZdZd Zd
defdZd
defdZd
defdZ	d
defd	Z
y)Clientu  A class that handles API requests to SerpApi in a user–friendly manner.

    :param api_key: The API Key to use for SerpApi.com.

    Please provide ``api_key`` when instantiating this class. We recommend storing this in an environment variable, like so:

        .. code-block:: bash

            $ export SERPAPI_KEY=YOUR_API_KEY

        .. code-block:: python

            import os
            import serpapi

            serpapi = serpapi.Client(api_key=os.environ["SERPAPI_KEY"])

    zhttps://serpapi.com/dashboardc                      y)Nz<SerpApi Client> )selfs    I/var/www/html/Manimaran/venv/lib/python3.12/site-packages/serpapi/core.py__repr__zClient.__repr__   s    !    Nparamsc                     |i }|r|j                  |       | j                  dd|      }t        j                  ||       S )aO  Fetch a page of results from SerpApi. Returns a :class:`SerpResults <serpapi.client.SerpResults>` object, or unicode text (*e.g.* if ``'output': 'html'`` was passed).

        The following three calls are equivalent:

        .. code-block:: python

            >>> s = serpapi.search(q="Coffee", location="Austin, Texas, United States")

        .. code-block:: python

            >>> params = {"q": "Coffee", "location": "Austin, Texas, United States"}
            >>> s = serpapi.search(**params)

        .. code-block:: python

            >>> params = {"q": "Coffee", "location": "Austin, Texas, United States"}
            >>> s = serpapi.search(params)


        :param q: typically, this is the parameter for the search engine query.
        :param engine: the search engine to use. Defaults to ``google``.
        :param output: the output format desired (``html`` or ``json``). Defaults to ``json``.
        :param api_key: the API Key to use for SerpApi.com.
        :param **: any additional parameters to pass to the API.


        **Learn more**: https://serpapi.com/search-api
        GETz/searchr   client)updaterequestr   from_http_responser
   r   kwargsrs       r   searchzClient.search   sD    : >FMM&!LL	&L9--a==r   c                     |i }|r|j                  |       	 |d   }| j	                  dd| |      }t        j                  ||       S # t        $ r t        d| j                         w xY w)a  Get a result from the SerpApi Search Archive API.

        :param search_id: the Search ID of the search to retrieve from the archive.
        :param api_key: the API Key to use for SerpApi.com.
        :param output: the output format desired (``html`` or ``json``). Defaults to ``json``.
        :param **: any additional parameters to pass to the API.

        **Learn more**: https://serpapi.com/search-archive-api
        	search_idz(Please provide 'search_id', found here: r   z
/searches/r   r   )r   KeyErrorr   DASHBOARD_URLr   r   r   )r
   r   r   r   r   s        r   search_archivezClient.search_archiveF   s     >FMM&!	{+I LL*iM :6LJ--a==  	%:D<N<N:PQ 	s   A "A.c                 z    |i }|r|j                  |       | j                  dd|d      }|j                         S )aF  Get a list of supported Google locations.


        :param q: restricts your search to locations that contain the supplied string.
        :param limit: limits the number of locations returned.
        :param **: any additional parameters to pass to the API.

        **Learn more**: https://serpapi.com/locations-api
        r   z/locations.jsonTr   
assert_200r   r   jsonr   s       r   	locationszClient.locations`   sI     >FMM&!LL	  
 vvxr   c                 z    |i }|r|j                  |       | j                  dd|d      }|j                         S )zGet SerpApi account information.

        :param api_key: the API Key to use for SerpApi.com.
        :param **: any additional parameters to pass to the API.

        **Learn more**: https://serpapi.com/account-api
        r   z/account.jsonTr!   r#   r   s       r   accountzClient.accountx   s>     >FMM&!LL4LPvvxr   )N)__name__
__module____qualname____doc__r   r   dictr   r   r%   r'   r	   r   r   r   r      sD    & 4M"%>T %>N>T >4 0d r   r   N)httpr   
exceptionsr   modelsr   r   _clientr   r   r%   r'   r	   r   r   <module>r1      sN     + BZ BL (	''	
//r   