Skip to main content

A Python library for extracting structured data from web pages using AI.

Project description

SpiderAI

A Python library for extracting structured data from web pages using AI. This library uses Google's Gemini AI to intelligently extract and format data according to your specified schema.

Features

  • Easy-to-use interface for web data extraction
  • AI-powered content analysis using Google's Gemini AI
  • Flexible schema definition for structured data extraction
  • Automatic handling of web page fetching and parsing

Installation

pip install spiderai

Quick Start

  1. First, get your Gemini AI API key from Google AI Studio

  2. Create a .env file in your project root and add your API key:

GEMINI_API_KEY=your_api_key_here
  1. Use the library in your code:
from spiderai import WebDataExtractor
import os
from dotenv import load_dotenv

# Load API key from .env file
load_dotenv()
gemini_api_key = os.getenv("GEMINI_API_KEY")

# Create the extractor
extractor = WebDataExtractor(api_key=gemini_api_key)

# URL to extract data from
url = "https://yoururl.com"

# Define your schema
schema = {
    "key1": "string",
    "key2": "float",
    "key3": "string"
}

# Extract the data
result = extractor.extract(url, schema)

# Use the extracted data
print("Product Name:", result["key1"])
print("Price:", result["key2"])
print("Description:", result["key3"])

Schema Definition

The schema is a dictionary where:

  • Keys are the field names you want to extract
  • Values are the expected data types ("string", "float", "integer", etc.)

Example schema:

# Product schema
schema = {
    "name": "string",
    "price": "float",
    "rating": "float",
    "review_count": "integer"
}

Requirements

  • Python 3.10 or higher
  • Google Gemini AI API key
  • Internet connection for web scraping and AI processing

License

This project is licensed under Apache 2.0. See the LICENSE file for details.

Contact

Feel free to contribute to the project by opening issues or suggesting improvements. For any queries, you can reach me at abhinavcv007@gmail.com

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

spiderai-0.0.2.tar.gz (8.0 kB view details)

Uploaded Source

Built Distribution

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

spiderai-0.0.2-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file spiderai-0.0.2.tar.gz.

File metadata

  • Download URL: spiderai-0.0.2.tar.gz
  • Upload date:
  • Size: 8.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.15

File hashes

Hashes for spiderai-0.0.2.tar.gz
Algorithm Hash digest
SHA256 8f3e2cc9eb6f97585a2501613fb8c1d49661c30bcf1f6e751af326297ed24103
MD5 5e7679df11d4ca8adffafd7b0e79533e
BLAKE2b-256 750e481c27558bd3196dc020aa6b8491ad6f6da12407233eeadc0d55a6119983

See more details on using hashes here.

File details

Details for the file spiderai-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: spiderai-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 8.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.15

File hashes

Hashes for spiderai-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 82b630b96e4d5a90ee8e32ebd5f2479bb46c9e143db1ed32c1c9d8e63ad711c9
MD5 544fb946ee65457e932e4a75dc826401
BLAKE2b-256 2ad2dcbb436503bd45b59bca519ab8ed907ab25cc78ffe60f12fb5d561fe3053

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