Skip to main content

Enumerate, Search, Parse, and Iterate - A tool for structured data extraction from search results

Project description

espai (Enumerate, Search, Parse, and Iterate)

A powerful tool for structured data extraction from search results using Google Search or Exa.ai with Gemini AI.

Features

  • Parse natural language queries into structured search parameters
  • Automatically discover and enumerate search spaces
  • Multiple search providers (Google Custom Search, Exa.ai)
  • Extract structured data from search results using Gemini AI
  • Store results in efficient Polars DataFrames
  • Real-time progress tracking
  • Multiple output formats (CSV, JSON, Parquet)

Installation

From PyPI

pip install espai

From Source

git clone https://github.com/yourusername/espai.git
cd espai
poetry install

API Key Setup

Google Custom Search

  1. Create a Google Custom Search Engine:

    • Go to Google Programmable Search Engine
    • Click "Add" to create a new search engine
    • Under "Sites to search", select "Search the entire web" for unrestricted search
    • Click "Create"
    • Copy your "Search engine ID" (this will be your GOOGLE_CSE_ID)
  2. Get a Google API Key:

    • Go to Google Cloud Console
    • Create a new project or select an existing one
    • Enable the "Custom Search API" for your project
    • Go to "Credentials" and create an API key (this will be your GOOGLE_API_KEY)
  3. Set environment variables:

export GOOGLE_API_KEY="your_google_api_key"
export GOOGLE_CSE_ID="your_search_engine_id"

Exa.ai (Optional)

  1. Sign up at Exa.ai
  2. Get your API key from the dashboard
  3. Set environment variable:
export EXA_API_KEY="your_exa_api_key"

Gemini AI

  1. Go to Google AI Studio API Keys
  2. Create an API key (no credit card required)
  3. Set environment variable:
export GEMINI_API_KEY="your_gemini_api_key"

Usage

Basic usage:

espai "Athletic center names and addresses in all California zip codes"

With options:

espai "Athletic center names and addresses in all California zip codes" \
  --max-results=10 \
  --output-format=csv \
  --provider=exa

Available options:

  • --max-results, -n: Maximum number of results per search (default: 10)
  • --output-format, -f: Output format: csv, json, or parquet (default: csv)
  • --output-file, -o: Output file path (default: results.[format])
  • --verbose, -v: Show verbose output
  • --temperature, -t: Temperature for LLM generation (0.0 to 1.0)
  • --provider, -p: Search provider: google or exa (default: google)

Search Provider Comparison

Google Custom Search

  • Pros:
    • More precise keyword matching
    • Better for finding specific attributes
    • Reliable and stable API
  • Cons:
    • Limited to 100 queries per day on free tier
    • Maximum 10 results per query
    • Requires setting up a custom search engine

Exa.ai

  • Pros:
    • Better semantic understanding
    • Returns more context in results
    • Up to 100 results per query
    • No need to set up a search engine
  • Cons:
    • May be less precise for specific attribute searches
    • API is newer and may change
    • Requires paid subscription for production use

Example Queries

Find businesses:

espai "Coffee shop names and addresses in Seattle neighborhoods"

Research organizations:

espai "Research labs working on AI in Massachusetts universities"

Gather event information:

espai "Tech conferences and their dates in European cities in 2024"

License

MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

espai-0.1.1.tar.gz (13.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

espai-0.1.1-py3-none-any.whl (15.4 kB view details)

Uploaded Python 3

File details

Details for the file espai-0.1.1.tar.gz.

File metadata

  • Download URL: espai-0.1.1.tar.gz
  • Upload date:
  • Size: 13.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.13.1 Darwin/23.4.0

File hashes

Hashes for espai-0.1.1.tar.gz
Algorithm Hash digest
SHA256 98c737ec6820904c64bbb6f7504c6267af3b78f9dab97d75fc9ae7111dd2cc99
MD5 f3b82fd963bdf9cd601f1056fc6d6270
BLAKE2b-256 5f7fe842a50b93bf2cdc08c346241465d414f5115f31e2c4a6191fa10e567870

See more details on using hashes here.

File details

Details for the file espai-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: espai-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 15.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.13.1 Darwin/23.4.0

File hashes

Hashes for espai-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 81987d2d343092cb24141a15b16d90bf1fd96109e11f70b71f8278c915941233
MD5 55d4b7157bbb9c321036119ec84dc052
BLAKE2b-256 62f70f6171e7f7f16f6204a7832c9a18a48fa4f8ccde3660ba7284ed5fce6403

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page