INNER CODE UNIT · Python

searxng

essamamdani/search-result-scraper-markdown · main.py:262

def searxng(query: str, categories: str = "general") -> list:
    searxng_url = f"{SEARXNG_URL}/search?q={query}&categories={categories}&format=json"
    try:
        response = httpx.get(searxng_url, headers=HEADERS, timeout=REQUEST_TIMEOUT)
        response.raise_for_status()
    except httpx.RequestError as e:
        return [{"error": f"Search query failed with error: {e}"}]
    except httpx.HTTPStatusError as e:
        return [{"error": f"Search query failed with HTTP error: {e}"}]

    search_results = response.json()
    return search_results

def search(query: str, num_results: int, json_response: bool = False) -> list:
    search_results = searxng(query)
    if FILTER_SEARCH_RESULT_BY_AI:
        search_results = rerenker_ai(search_results)

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…