1. Go to this page and download the library: Download rkdhatterwal/decodo-scraper library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
rkdhatterwal / decodo-scraper example snippets
use Rkdhatterwal\DecodoScraper\Facades\Decodo;
// Simple scrape → ScrapeResult
$result = Decodo::scrape('https://example.com');
echo $result->content; // raw HTML
echo $result->statusCode; // upstream HTTP status
// JavaScript rendering
$result = Decodo::scrapeWithJs('https://example.com');
// Screenshot (PNG)
$result = Decodo::screenshot('https://example.com');
// Geo-targeted
$result = Decodo::scrapeFromGeo('https://example.com', 'United States');
// Return Markdown (great for LLM pipelines)
$result = Decodo::scrapeAsMarkdown('https://example.com');
// Structured data via a target template's parser
$result = Decodo::scrapeWithParser('amazon_pricing', 'https://amazon.com/dp/B0BS1QCF');
// Scrape multiple URLs at once
$results = Decodo::scrapeMany(['https://example.com', 'https://another.com']);
use Rkdhatterwal\DecodoScraper\PayloadBuilder;
use Rkdhatterwal\DecodoScraper\Facades\Decodo;
$results = Decodo::send(
(new PayloadBuilder())
->url('https://example.com')
->headless('html')
->geo('Germany')
->locale('de-DE')
->deviceType('mobile')
->proxyPool('premium')
->markdown()
->successfulStatusCodes([200, 301])
);
$product = Product::find(1);
DecodoAsync::queueTask('https://example.com', scrapeable: $product);
// Later retrieve it
$task = $product->decodoTasks()->latest()->first();
use Rkdhatterwal\DecodoScraper\Facades\DecodoAsync;
// Queue and get a task ID immediately
$task = DecodoAsync::queueTask('https://example.com');
echo $task->id; // "7434928397127555073"
echo $task->status; // "pending"
// With a webhook callback
$task = DecodoAsync::queueTask(
url: 'https://example.com',
options: ['headless' => 'html', 'geo' => 'United States'],
callbackUrl: 'https://my.app/webhook/decodo',
passthrough: 'my-verification-secret', // echoed back for auth
);
use Rkdhatterwal\DecodoScraper\PayloadBuilder;
use Rkdhatterwal\DecodoScraper\Facades\DecodoAsync;
$task = DecodoAsync::queueTaskWithBuilder(
(new PayloadBuilder())
->url('https://example.com')
->headless('html')
->geo('United States')
->markdown()
);
$batch = DecodoAsync::queueBatch(
urls: ['https://site1.com', 'https://site2.com', 'https://site3.com'],
options: ['geo' => 'United States'],
callbackUrl: 'https://my.app/webhook/decodo-batch',
batchName: 'Weekly SEO Audit', // Optional name for easier tracking
);
$batch->id; // Internal batch ID (v3)
$batch->tasks; // Collection of TaskResponse DTOs
$batch->ids(); // Collection of task IDs
$batch->count(); // 3
// Example: notify when a batch finishes
Event::listen(DecodoBatchCompleted::class, function ($event) {
Log::info("Batch {$event->batch->id} is done!");
});
'pruning' => [
'content_days' => 7, // Keep raw HTML for 7 days
'tasks_days' => 30, // Keep task records for 30 days
'pending_tasks_days' => 3, // Delete abandoned tasks after 3 days
'batches_days' => 60, // Keep batch records for 60 days
'schedule_enabled' => true,
'schedule_frequency' => 'daily', // Laravel scheduler frequency
],
$result->isSuccessful(); // true when statusCode is 2xx
$result->toArray();
$task->id; // Task ID for later retrieval
$task->status; // "pending" | "done" | "faulted"
$task->isPending(); // bool
$task->isDone(); // bool
$task->isFaulted(); // bool
$task->toArray();
$batch->id; // Batch ID (v3)
$batch->tasks; // Collection of TaskResponse DTOs
$batch->ids(); // Collection of task IDs
$batch->count(); // Total task count
$batch->toArray();