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
-
First, get your Gemini AI API key from Google AI Studio
-
Create a
.envfile in your project root and add your API key:
GEMINI_API_KEY=your_api_key_here
- 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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8f3e2cc9eb6f97585a2501613fb8c1d49661c30bcf1f6e751af326297ed24103
|
|
| MD5 |
5e7679df11d4ca8adffafd7b0e79533e
|
|
| BLAKE2b-256 |
750e481c27558bd3196dc020aa6b8491ad6f6da12407233eeadc0d55a6119983
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
82b630b96e4d5a90ee8e32ebd5f2479bb46c9e143db1ed32c1c9d8e63ad711c9
|
|
| MD5 |
544fb946ee65457e932e4a75dc826401
|
|
| BLAKE2b-256 |
2ad2dcbb436503bd45b59bca519ab8ed907ab25cc78ffe60f12fb5d561fe3053
|