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 MIT License

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.3.tar.gz (4.7 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.3-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: spiderai-0.0.3.tar.gz
  • Upload date:
  • Size: 4.7 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.3.tar.gz
Algorithm Hash digest
SHA256 b0d35b3c679982ae086c1424f5f51741522c91d98bd4d62ea15f08f93ba8a5c3
MD5 2d663a7994c3717f290b162f9e02bfe8
BLAKE2b-256 16c15aafef62e4beafa744b58f25dd493a4facef5930d41c2728a4222cd38227

See more details on using hashes here.

File details

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

File metadata

  • Download URL: spiderai-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 4.6 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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 99daf6d1a989d2d01b92b0401f5fa98aa73c5b26ac23a7ee65fac76c7757dd5b
MD5 ef02b953cfb241228130b0bb80f643e2
BLAKE2b-256 d587b01cb28ed8621bcca5adf43b529de1412668b3d8701550b342b18a8e7d31

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