PHP code example of ziming / laravel-scrapingbee
1. Go to this page and download the library: Download ziming/laravel-scrapingbee 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/ */
ziming / laravel-scrapingbee example snippets
return [
'api_key' => env('SCRAPINGBEE_API_KEY'),
'base_url' => env('SCRAPINGBEE_BASE_URL', 'https://app.scrapingbee.com/api/v1/'),
'timeout' => env('SCRAPINGBEE_TIMEOUT', 120),
];
$scrapingBeeClient = Ziming\LaravelScrapingBee\LaravelScrapingBee::make();
$response = $scrapingBeeClient->blockAds()
->when(now()->weekOfMonth === 4, function (LaravelScrapingBee $scrapingBeeClient): LaravelScrapingBee {
// if it is last week of the month, spam premium proxy to use up credits!
return $scrapingBeeClient->premiumProxy();
})
->jsonResponse()
->jsScenario([
['click' => '#button_id'],
['wait' => 1000],
['wait_for' => '#slow_div'],
['scroll_x' => 1000],
['scroll_y' => 1000],
['fill' => ['#input_1','value_1']],
['evaluate' => 'console.log(window);'],
])->get('https://www.scrapingbee.com')
$scrapingBeeClient = Ziming\LaravelScrapingBee\LaravelScrapingBee::make();
$response = $scrapingBeeClient->setParams([
'js_scenario' => json_encode([
'instructions' => [
['click' => '#button_id'],
['wait' => 1000],
['wait_for' => '#slow_div'],
['scroll_x' => 1000],
['scroll_y' => 1000],
['fill' => ['#input_1','value_1']],
['evaluate' => 'console.log(window);']
]
]),
'block_ads' => true,
'json_response' => true,
])->get('https://www.scrapingbee.com')
$googleSearchScrapingBeeClient = Ziming\LaravelScrapingBee\LaravelScrapingBeeGoogleSearch::make();
$response = $googleSearchScrapingBeeClient
->nbResults(8)
->page(1)
->search('scrapingbee')
->get();
bash
php artisan vendor:publish --provider="Ziming\LaravelScrapingBee\LaravelScrapingBeeServiceProvider" --tag="laravel-scrapingbee-config"