Skip to main content

Python SDK for the Rocket Scraper API.

Project description

Rocket Scraper API Python SDK

Python SDK for the Rocket Scraper API. For more information, visit the GitHub repository.

Requirements

Installation

pip install rocketscraper

Usage

To use the SDK, you need to create a new instance of the RocketClient class and pass your API key as an argument.

Setup

from rocketscraper import RocketClient

rocket_client = RocketClient('YOUR_API_KEY')  # Simplified constructor

Scrape

The scrape method allows you to scrape data from a website using a schema. The method returns the scraped data in the format specified in the schema.

from rocketscraper import RocketClient

try:
    client = RocketClient('YOUR_API_KEY')
    
    # Define a comprehensive product schema
    schema = {
        "productDetails": {
            "name": "string",
            "brand": "string",
            "currentPrice": "number",
            "originalPrice": "number",
            "discount": "number",
            "availability": "boolean",
            "rating": "number",
            "reviewCount": "integer"
        },
        "specifications": [{
            "name": "string",
            "value": "string"
        }],
        "shipping": {
            "freeShipping": "boolean",
            "estimatedDays": "integer"
        }
    }
    
    # Add a detailed task description for better accuracy (optional)
    task_description = """
    Extract product information with the following guidelines:
    1. For prices, use the main displayed price (ignore bulk discounts)
    2. Calculate discount percentage from original and current price
    3. Include all technical specifications found on the page
    4. Extract shipping details from both product and shipping sections
    """
    
    result = client.scrape(
        url='https://marketplace.example.com/products/wireless-earbuds',
        schema=schema,
        task_description=task_description
    )
    print(result)

except Exception as e:
    print(f"Error: {e}")

Example Output

{
    "productDetails": {
        "name": "Premium Wireless Earbuds Pro X",
        "brand": "AudioTech",
        "currentPrice": 149.99,
        "originalPrice": 199.99,
        "discount": 25.0,
        "availability": true,
        "rating": 4.5,
        "reviewCount": 328
    },
    "specifications": [
        {
            "name": "Battery Life",
            "value": "Up to 8 hours (single charge)"
        },
        {
            "name": "Connectivity",
            "value": "Bluetooth 5.2"
        },
        {
            "name": "Water Resistance",
            "value": "IPX4"
        }
    ],
    "shipping": {
        "freeShipping": true,
        "estimatedDays": 3
    }
}

Error Handling

The SDK will raise exceptions for various error cases. It's recommended to wrap your API calls in try-catch blocks to handle potential errors gracefully.

Common error scenarios:

  • Invalid API key
  • Invalid URL
  • Invalid schema format

Documentation

For more information on how to use the Rocket Scraper API, visit the Rocket Scraper API documentation.

License

This project is licensed under the MIT License. See the LICENSE file for more details.

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

rocketscraper-0.0.4.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

rocketscraper-0.0.4-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

Details for the file rocketscraper-0.0.4.tar.gz.

File metadata

  • Download URL: rocketscraper-0.0.4.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.1

File hashes

Hashes for rocketscraper-0.0.4.tar.gz
Algorithm Hash digest
SHA256 2521d19bfd213dc2e0e204e23dbad339e13059c97c35d3f643bfdbcbf15b449a
MD5 1e0588bc089fc55a0b6ab9c0a8949841
BLAKE2b-256 08d37896f39695031f42411a1293f9c7b22c76a43cc09d67893e3bca27342d49

See more details on using hashes here.

File details

Details for the file rocketscraper-0.0.4-py3-none-any.whl.

File metadata

File hashes

Hashes for rocketscraper-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 495372bd5e59923225dba393ab048222a36eca8074bcfdff1bc545d5119217e2
MD5 8310f77591f774722f752b03345b9a7c
BLAKE2b-256 c42046de453a4b3e6c7be1a84f3fd6860fde1e4596b46d34cc486194eb31d77d

See more details on using hashes here.

Supported by

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