cuery.seo.aio.hasdata ===================== .. py:module:: cuery.seo.aio.hasdata .. autoapi-nested-parse:: HasData AI Overview async helpers. Functions --------- .. autoapisummary:: cuery.seo.aio.hasdata._clean_text cuery.seo.aio.hasdata._iter_list_items cuery.seo.aio.hasdata._format_table cuery.seo.aio.hasdata._format_code cuery.seo.aio.hasdata.parse_aio cuery.seo.aio.hasdata.aio_request_params cuery.seo.aio.hasdata.query cuery.seo.aio.hasdata.gather Module Contents --------------- .. py:function:: _clean_text(text) Normalize whitespace inside extracted snippets. Collapses multiple spaces, trims each line and removes trailing spaces while preserving single newlines. Empty lines are kept only once. .. py:function:: _iter_list_items(items, indent = 0) Yield bullet-point lines from a (possibly nested) list block structure. .. py:function:: _format_table(block) .. py:function:: _format_code(block) .. py:function:: parse_aio(aio) Parse HasData ``aiOverview`` object into a unified ``SearchResult``. Documentation: https://docs.hasdata.com/apis/google-serp-api/rich-snippets/ai-overview We concatenate textual content from the following block *types* in order: paragraph, list (including nested lists), table, code, video (snippet), carousel (ignored – mostly images). Unknown types are skipped silently to remain forward-compatible. Lists are flattened into bullet points. Tables become pipe-delimited lines with the first row treated as a header. Code blocks are prefixed with a ``[Code:]`` marker. Whitespace is normalized and excessive blank lines removed. .. py:function:: aio_request_params(aio) Check if we need to make a second request to get the actual AI overview. https://docs.hasdata.com/apis/google-serp-api/rich-snippets/ai-overview#ai-overview-with-extra-request .. py:function:: query(prompt, country = None, language = None, validate = True, log = False, session = None) :async: Asynchronously execute a Google search via HasData and extract AI Overview. :param prompt: Query string. :param country: Optional 2-letter country code (gl param). :param language: Optional 2-letter language code (hl param). :param validate: If True return parsed ``SearchResult``, else raw dict. :param log: If True, log request/response bodies. :param session: Optional existing ``aiohttp.ClientSession`` to reuse. If not provided a temporary session is created and closed. .. py:function:: gather(prompts, country = None, language = None, validate = True, log = False, session = None, policies = None, execute = True) :async: Create zero-argument coroutine factories (with policies) for many prompts.