I have a webcrawler application. And I try to return some search results.
And I do it with this method:
[
'htmlOptions' => ['style' => 'width: 150px'],
'name' => 'coc_number',
'value' => function (Result $result) {
$requestString = Google::GOOGLE_BASE_URL . 'key=' . Google::GOOGLE_API_KEY .
'&cx=' . Google::GOOGLE_CX . '&q=' . $result->page_url .
'"kvk"' . '&lr=lang_nl';
$clear = GuzzleHttpjson_decode((new Client)->request('GET', $requestString)->getBody()->getContents());
if (property_exists($clear, 'items'))
foreach ($clear->items as $item)
if (property_exists($item, 'snippet'))
if (strpos(($item->snippet), 'KvK') !== false) {
preg_match('/[0-9]{8}/', $item->snippet, $match);
if (isset($match[0])) {
$result->coc_number = $match[0];
$result->save();
}
sleep(4);
}
$this->redirect(Yii::app()->request->urlReferrer);
return $result->coc_number;
}
],
But when I execute this. I get this error:
GuzzleHttpExceptionClientException
Client error: `GET https://www.googleapis.com/customsearch/v1?key=AIzaSyC_xG9bUrJ2VcwHdRnB51rU3xbN2w2Zz7k&cx=017807248161955378400:1yvjei2ww6r&q=4%20Juli%20deken%20kopen%20bestellen&lr=lang_nl&num=10&start=1` resulted in a `429 Too Many Requests` response:
{
"error": {
"code": 429,
"message": "Quota exceeded for quota metric 'Queries' and limit 'Queries per day' of (truncated...)
So my question is: how to solve this?