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', 140),
'google_search_base_url' => env('SCRAPINGBEE_GOOGLE_SEARCH_BASE_URL', 'https://app.scrapingbee.com/api/v1/store/google'),
'fast_search_base_url' => env('SCRAPINGBEE_FAST_SEARCH_BASE_URL', 'https://app.scrapingbee.com/api/v1/fast_search'),
'walmart_search_base_url' => env('SCRAPINGBEE_WALMART_SEARCH_BASE_URL', 'https://app.scrapingbee.com/api/v1/walmart/search'),
'walmart_product_base_url' => env('SCRAPINGBEE_WALMART_PRODUCT_BASE_URL', 'https://app.scrapingbee.com/api/v1/walmart/product'),
'amazon_search_base_url' => env('SCRAPINGBEE_AMAZON_SEARCH_BASE_URL', 'https://app.scrapingbee.com/api/v1/amazon/search'),
'amazon_product_base_url' => env('SCRAPINGBEE_AMAZON_PRODUCT_BASE_URL', 'https://app.scrapingbee.com/api/v1/amazon/product'),
'gemini_base_url' => env('SCRAPINGBEE_GEMINI_BASE_URL', 'https://app.scrapingbee.com/api/v1/gemini'),
'chatgpt_base_url' => env('SCRAPINGBEE_CHATGPT_BASE_URL', 'https://app.scrapingbee.com/api/v1/chatgpt'),
];
$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()
//->aiQuery('top 5 blog posts') // AI Query Feature!
//->aiExtractRules(['title' => 'title of post', 'summary' => 'summary of post']) // AI Extract Feature!
->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
->page(1)
->search('scrapingbee')
->get();
$fastSearchScrapingBeeClient = Ziming\LaravelScrapingBee\LaravelScrapingBeeFastSearch::make();
$response = $fastSearchScrapingBeeClient
->search('pizza in new york')
->countryCode('us')
->page(1)
->tag('search-example')
->get();
$walmartSearchScrapingBeeClient = Ziming\LaravelScrapingBee\LaravelScrapingBeeWalmartSearch::make();
$response = $walmartSearchScrapingBeeClient
->query('iPhone')
->minPrice(100)
->maxPrice(1000)
->fulfillmentType('in_store')
->fulfillmentSpeed('today')
->domain('walmart.ca')
->sortBy('price_low')
->page(2)
->get();
$walmartProductScrapingBeeClient = Ziming\LaravelScrapingBee\LaravelScrapingBeeWalmartProduct::make();
$response = $walmartProductScrapingBeeClient
->productId('5491199371')
->domain('walmart.ca')
->deliveryZip('10001')
->storeId('3520')
->get();
$amazonSearchScrapingBeeClient = Ziming\LaravelScrapingBee\LaravelScrapingBeeAmazonSearch::make();
$response = $amazonSearchScrapingBeeClient
->query('iPhone')
->startPage(2)
->pages(3)
->device('desktop')
->currency('usd')
->country('gb')
->sortBy('average_review')
->get();
$amazonProductScrapingBeeClient = Ziming\LaravelScrapingBee\LaravelScrapingBeeAmazonProduct::make();
$response = $amazonProductScrapingBeeClient
->query('ASIN')
->device('desktop')
->currency('usd')
->country('gb')
->get();
$youTubeScrapingBeeSearchClient = Ziming\LaravelScrapingBee\LaravelScrapingBeeYouTubeSearch::make();
$response = $youTubeScrapingBeeSearchClient
->search('Python Tutorial')
->get();
$youTubeScrapingBeeMetadataClient = Ziming\LaravelScrapingBee\LaravelScrapingBeeYouTubeMetadata::make();
$response = $youTubeScrapingBeeMetadataClient
->videoId('rfscVS0vtbw')
->get();
$youTubeScrapingBeeTranscriptClient = Ziming\LaravelScrapingBee\LaravelScrapingBeeYouTubeTranscript::make();
$response = $youTubeScrapingBeeTranscriptClient
->videoId('rfscVS0vtbw')
->language('es')
->transcriptOrigin('uploader_provided')
->get();
$youTubeScrapingBeeTrainabilityClient = Ziming\LaravelScrapingBee\LaravelScrapingBeeYouTubeTrainability::make();
$response = $youTubeScrapingBeeTrainabilityClient
->videoId('rfscVS0vtbw')
->get();
$chatGptScrapingbeeClient = Ziming\LaravelScrapingBee\LaravelScrapingBeeChatGpt::make();
$response = $chatGptScrapingbeeClient
->prompt('Explain why a career in web development is a bad choice')
->search()
->countryCode('us')
->addHtml()
->tag('career-advice')
->get();
$geminiScrapingbeeClient = Ziming\LaravelScrapingBee\LaravelScrapingBeeGemini::make();
$response = $geminiScrapingbeeClient
->prompt('Best programming languages for data science')
->countryCode('US')
->tag('research')
->addHtml()
->get();
bash
php artisan vendor:publish --provider="Ziming\LaravelScrapingBee\LaravelScrapingBeeServiceProvider" --tag="laravel-scrapingbee-config"