diff --git a/app/Http/Controllers/WebCrawlController.php b/app/Http/Controllers/WebCrawlController.php index 379b2d7..e22c4ca 100644 --- a/app/Http/Controllers/WebCrawlController.php +++ b/app/Http/Controllers/WebCrawlController.php @@ -20,7 +20,7 @@ public function index() public function crawlWebsite(Request $request) { $url = $request->query('url'); - $depth = $request->query('depth', 1); + $depth = $request->query('depth', 0); $refresh = $request->query('refresh', false); // Check if the URL is already in the database @@ -122,7 +122,13 @@ protected function getLinksFromPage($crawlerContent) protected function scan($url) { - $result = $this->webClient->request('GET', $url); + try { + $result = $this->webClient->request('GET', $url); + } catch (\Exception $e) { + return response()->json([ + 'error' => 'Failed to retrieve the URL', + ], 500); + } return $result; }