I'm making a request to URL to get data using Goutte. But the server where I'm making request is slow. So sometimes laravel throws error of time out. When this error comes, I have to make entry of this error log in databse with some additional data (i.e, id etc). I have searched on internet. But I found all solutions related to customise error message etc. What I want is when laravel throws error of time out, I have to make entry in database with additional data and then redirect page. If any one knows the solution, it will be appreciated.
Here is my code.
use Goutte\Client;
class WebScrapingController extends Controller {
public function index() {
try {
$this->crawler = $this->client->request('GET', $url . '?' . $data);
}catch(Exception $e){
// Here I want to make entry in database and then redirect to another page
dd(['Connection time out', $i, $e]);
}
}
}
Here is my error message
ConnectException in CurlFactory.php line 186:
cURL error 7: Failed to connect to myurl port 80: Connection timed out (see http://ift.tt/1mgwZgQ)
I'm using laravel 5.3 and this scraper.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire