← ClaudeAtlas

scraperapi-php-sdklisted

Best-practices reference for the ScraperAPI PHP SDK (scraperapi/sdk Composer package). Consult whenever the user is writing, debugging, or reviewing PHP code that calls ScraperAPI. Use when user asks: "scrape a website with PHP and ScraperAPI", "ScraperAPI PHP example", "how do I use the ScraperAPI PHP SDK", "PHP ScraperAPI render", "ScraperAPI PHP premium proxy", "ScraperAPI PHP Composer install", "ScraperAPI PHP error handling". Covers Composer setup, all request parameters, the escalation ladder, POST requests, error handling, and credit costs.
scraperapi/scraperapi-skills · ★ 9 · AI & Automation · score 78
Install: claude install-skill scraperapi/scraperapi-skills
# ScraperAPI — PHP SDK Best Practices **Requires:** PHP 7.0+, Composer, `composer require scraperapi/sdk`, `SCRAPERAPI_API_KEY` environment variable. ## Setup ```php <?php require __DIR__ . '/vendor/autoload.php'; use ScraperAPI\Client; $client = new Client(getenv('SCRAPERAPI_API_KEY')); ``` Never hardcode the API key. Read it from the environment every time. ## Basic Usage ```php // Simple GET — returns HTML string via ->raw_body $html = $client->get("https://example.com/")->raw_body; echo $html; // With a single parameter $html = $client->get("https://example.com/", ["render" => true])->raw_body; // With multiple parameters $html = $client->get( "https://example.com/", [ "render" => true, "country_code" => "us", ] )->raw_body; ``` Parameters are passed as an associative array. `->raw_body` extracts the HTML string from the response object. ## Decision Guide | Situation | Approach | |-----------|---------| | Single URL, synchronous | `$client->get($url, $params)->raw_body` | | Page loads content via JavaScript | Add `"render" => true` | | Site blocks datacenter proxies | Add `"premium" => true` | | Toughest anti-bot protection | Add `"ultra_premium" => true` | | Multi-step / paginated flow on same domain | Use `"session_number"` | | POST a form or JSON body to target | `$client->post($url, $options)->raw_body` | | 20+ URLs or batch jobs | Use async endpoint via cURL or Guzzle | | Supported platform (Amazon, Google, etc.) | Use st