Skip to content

Commit

Permalink
Guzzle exception
Browse files Browse the repository at this point in the history
  • Loading branch information
mertkuru committed Jan 18, 2021
1 parent 596a9ec commit 14716cb
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/Crawler.php
Original file line number Diff line number Diff line change
Expand Up @@ -223,11 +223,14 @@ protected function setAttributes($attributes)
protected function fetchUrl($url, $method = 'GET', $options = [])
{
$client = new GuzzleHttp\Client();
$res = $client->request($method, $url, $options);
if ($res->getStatusCode() == 200) {
return (string)$res->getBody();
try {
$res = $client->request($method, $url, $options);
if ($res->getStatusCode() == 200) {
return (string)$res->getBody();
}
} catch (\GuzzleHttp\Exception\ClientException $exception) {
return '';
}
return '';
}

/**
Expand Down

0 comments on commit 14716cb

Please sign in to comment.