1. Go to this page and download the library: Download crawlora/sdk 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/ */
crawlora / sdk example snippets
Crawlora\Client;
// Reads CRAWLORA_API_KEY from the environment if apiKey is omitted.
$client = new Client(['apiKey' => getenv('CRAWLORA_API_KEY') ?: '']);
$result = $client->bing->search(['q' => 'web scraping']);
foreach ($result['data'] as $item) {
echo $item['title'] ?? '', "\n";
}
$client->close(); // release the pooled curl connection
$client = new Client([
'apiKey' => '...',
// Mutate the outgoing request (pass $ctx by reference to edit url/headers).
'beforeRequest' => function (array &$ctx) {
$ctx['headers']['X-Trace'] = bin2hex(random_bytes(8));
},
// Inspect or replace the parsed body (return a value to replace it).
'afterResponse' => function (string $op, int $status, array $headers, $body) {
return $body;
},
]);