Skip to main content

Quick Start Guide

Get up and running with WebscrapingHQ API in under 5 minutes! This guide will walk you through making your first successful scraping request.

Prerequisites

Before you begin, make sure you have:

  1. ✅ A WebscrapingHQ account (Sign up here)
  2. ✅ Your API key (Get it from your dashboard)
  3. ✅ A tool to make HTTP requests (curl, Postman, or your preferred programming language)

Your First API Request

Let's start with the simplest possible request - scraping a basic webpage:

Using cURL

curl -X POST https://app.webscrapinghq.com/api/v1/scrape \
-H "X-API-KEY: your-api-key-here" \
-H "Content-Type: application/json" \
-d '{
"url": "https://httpbin.org/get"
}'

Expected Response

{
"creditsLeft": 999,
"cost": 1,
"initial-status-code": 200,
"resolved-url": "https://httpbin.org/get",
"type": "html",
"body": "<!DOCTYPE html>\n<html>...",
"features_used": {
"javascript": false,
"screenshot": false
}
}

🎉 Congratulations! You've successfully made your first scraping request.

Step-by-Step Walkthrough

Step 1: Set Up Your Environment

Choose your preferred method:

# Set your API key as an environment variable
export WEBSCRAPINGHQ_API_KEY="your-api-key-here"

# Test the connection
curl -X POST https://app.webscrapinghq.com/api/v1/scrape \
-H "X-API-KEY: $WEBSCRAPINGHQ_API_KEY" \
-H "Content-Type: application/json" \
-d '{"url": "https://httpbin.org/get"}'

Step 2: Add JavaScript Rendering

Many modern websites require JavaScript to load content. Enable JavaScript rendering:

{
"url": "https://example-spa.com",
"renderJs": true,
"waitFor": 3000
}
curl -X POST https://app.webscrapinghq.com/api/v1/scrape \
-H "X-API-KEY: $WEBSCRAPINGHQ_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"url": "https://example-spa.com",
"renderJs": true,
"waitFor": 3000
}'

Step 3: Capture Screenshots

Add visual verification with screenshots:

{
"url": "https://example.com",
"screenshot": true,
"deviceType": "desktop"
}

The response will include a base64-encoded screenshot:

{
"screenshot": "iVBORw0KGgoAAAANSUhEUgAAA...",
"body": "<!DOCTYPE html>...",
"creditsLeft": 995,
"cost": 5
}

Step 4: AI-Powered Data Extraction

Extract specific data using AI:

{
"url": "https://news-website.com",
"aiScraping": [
{
"name": "headline",
"context": "Extract the main news headline"
},
{
"name": "author",
"context": "Find the article author name"
},
{
"name": "publish_date",
"context": "When was this article published"
}
]
}

Response with extracted data:

{
"aiResponse": {
"headline": "Breaking: Major Tech Announcement Today",
"author": "John Smith",
"publish_date": "2024-01-15"
},
"body": "<!DOCTYPE html>...",
"creditsLeft": 990,
"cost": 10
}

Common Use Cases

E-commerce Product Scraping

{
"url": "https://shop.example.com/product/123",
"renderJs": true,
"aiScraping": [
{
"name": "product_name",
"context": "Extract the product title or name"
},
{
"name": "price",
"context": "Find the current price"
},
{
"name": "availability",
"context": "Is the product in stock"
},
{
"name": "rating",
"context": "Product rating or review score"
}
]
}

News Article Extraction

{
"url": "https://news.example.com/article/456",
"renderJs": true,
"aiScraping": [
{
"name": "headline",
"context": "Main article headline"
},
{
"name": "summary",
"context": "Article summary or description"
},
{
"name": "content",
"context": "Full article text content"
},
{
"name": "tags",
"context": "Article tags or categories"
}
]
}

Social Media Monitoring

{
"url": "https://social.example.com/post/789",
"renderJs": true,
"waitFor": 5000,
"screenshot": true,
"aiScraping": [
{
"name": "post_content",
"context": "Extract the main post text"
},
{
"name": "engagement",
"context": "Likes, shares, comments count"
},
{
"name": "timestamp",
"context": "When was this posted"
}
]
}

Understanding the Response

Every successful response includes these key fields:

FieldDescriptionExample
creditsLeftRemaining credits in your account995
costCredits consumed by this request5
initial-status-codeHTTP status from target site200
resolved-urlFinal URL after redirectshttps://example.com/final
typeContent type returned"html"
bodyHTML content of the page"<!DOCTYPE html>..."
features_usedFeatures enabled for this request{"javascript": true}
screenshotBase64 image (if requested)"iVBORw0K..."
aiResponseAI-extracted data (if requested){"title": "..."}

Error Handling

Handle common errors gracefully:

import requests

def scrape_with_error_handling(url, options={}):
try:
headers = {
'X-API-KEY': API_KEY,
'Content-Type': 'application/json'
}

payload = {'url': url, **options}

response = requests.post(
'https://app.webscrapinghq.com/api/v1/scrape',
headers=headers,
json=payload,
timeout=30
)

if response.status_code == 200:
return response.json()
elif response.status_code == 401:
raise Exception("Invalid API key")
elif response.status_code == 429:
raise Exception("Rate limit exceeded")
elif response.status_code == 500:
raise Exception("Server error, please try again")
else:
raise Exception(f"Request failed: {response.status_code}")

except requests.exceptions.Timeout:
raise Exception("Request timed out")
except requests.exceptions.RequestException as e:
raise Exception(f"Network error: {str(e)}")

Next Steps

Now that you've made your first successful request, explore these features:

  1. JavaScript Instructions - Automate complex interactions
  2. Basic Scraping - Learn core concepts and strategies
  3. Authentication - Secure API usage

Need Help?


Next: Dive deeper into Basic Scraping Concepts to learn about different scraping strategies and optimizations.