A Python library for extracting structured data from web pages using AI.
Project description
Web Data Extractor
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 web_extractor
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 web_extractor 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://www.amazon.in/Celestron-AstroMaster-130-EQ-Telescope/dp/B000MLL6RS"
# Define your schema
schema = {
"name": "string",
"price": "float",
"description": "string"
}
# Extract the data
result = extractor.extract(url, schema)
# Use the extracted data
print("Product Name:", result["name"])
print("Price:", result["price"])
print("Description:", result["description"])
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 schemas:
# 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
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.1.tar.gz.
File metadata
- Download URL: spiderai-0.0.1.tar.gz
- Upload date:
- Size: 7.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
82da6a41a488360dfe800ca168e11caee120ab0115740f22bcce1c4fbc00a5d9
|
|
| MD5 |
a4d13a70af6082c1800b540c79656225
|
|
| BLAKE2b-256 |
3d93e81cc69a4be544ea1762ce16fd8e53007e8e49f3eee97fbdc579fbd50cff
|
File details
Details for the file spiderai-0.0.1-py3-none-any.whl.
File metadata
- Download URL: spiderai-0.0.1-py3-none-any.whl
- Upload date:
- Size: 7.9 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 |
d02146fc9ee41f8878a6f280089c5771d9a105eded7a4f9f82f7a0912b7c5d66
|
|
| MD5 |
98e60e40f9a8e66d8ae0b44f8640a496
|
|
| BLAKE2b-256 |
b26b9af945c8cca558e9e148ff063babfd630635c467d540bc7ebc0377a43d9c
|