Skip to main content

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.

Metadata

Release files for rocketscraper 0.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for rocketscraper 0.0.4
File Size Uploaded
rocketscraper-0.0.4.tar.gz 4.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for rocketscraper 0.0.4
File Interpreter ABI Platform
rocketscraper-0.0.4-py3-none-any.whl Python 3 none any Details

Total release size: 10.3 kB

Release files / rocketscraper-0.0.4.tar.gz

Download URL rocketscraper-0.0.4.tar.gz
Size 4.9 kB
Tags Source
SHA-256 checksum
How to use checksums
2521d19bfd213dc2e0e204e23dbad339e13059c97c35d3f643bfdbcbf15b449a
BLAKE2b-256 checksum
How to use checksums
08d37896f39695031f42411a1293f9c7b22c76a43cc09d67893e3bca27342d49
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.1

Release files / rocketscraper-0.0.4-py3-none-any.whl

Download URL rocketscraper-0.0.4-py3-none-any.whl
Size 5.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
495372bd5e59923225dba393ab048222a36eca8074bcfdff1bc545d5119217e2
BLAKE2b-256 checksum
How to use checksums
c42046de453a4b3e6c7be1a84f3fd6860fde1e4596b46d34cc486194eb31d77d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.1

Release history Release notifications | RSS feed

This release

0.0.4 This release

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page