Skip to content

AWS Waf

import requests


def fetch_result():
    url = "https://api.example.com/ocr"  # Replace with the actual API endpoint
    headers = {"Content-Type": "application/json"}

    data = {
        "apiKey": "sonic_xxxxxxxxxxxxxxxxxxxxxxxxxxx",
        "task": {
        "type": "AwsWafImage",
        "websiteURL": "https://your-website.com",
        "queries": [
        "iVBORw0KGgoAAAANSUhEUgAAASwAAADICAIAAADdvUsCAAAgAElEQVR4AezBCZRd9X0n...."
        ],
        "question": "aws:grid:chair"
    }

    try:
        response = requests.post(url, json=data, headers=headers)
        response.raise_for_status()  # Raise an error for HTTP error responses 
        (4xx, 5xx)
        return response.json()  # Return JSON response
    except requests.exceptions.RequestException as e:
        print(f"Error fetching OCR result: {e}")
        return None

# Example usage:
result = fetch_result()
if result:
    print("Response:", result)