diff --git a/composer.json b/composer.json index f210a7e..a38ecc9 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,7 @@ "require": { "php": "^8.1", - "giauphan/goutte": "*", + "giauphan/goutte": "^1.1", "guzzlehttp/guzzle": "^7.2", "illuminate/console": "*", "illuminate/database": "*" diff --git a/src/Commands/CrawlBlogData.php b/src/Commands/CrawlBlogData.php index 57d2a68..2014479 100644 --- a/src/Commands/CrawlBlogData.php +++ b/src/Commands/CrawlBlogData.php @@ -5,7 +5,7 @@ use Giauphan\CrawlBlog\Models\CategoryBlog; use Giauphan\CrawlBlog\Models\Post; use Illuminate\Console\Command; -use Weidner\Goutte\GoutteFacade; +use Giauphan\Client; use Illuminate\Support\Str; use Carbon\Carbon; use Symfony\Component\DomCrawler\Crawler; @@ -30,7 +30,8 @@ public function handle() $category = CategoryBlog::firstOrCreate(['name' => $categoryName], ['slug' => Str::slug($categoryName)]); $categoryId = $category->id; do { - $crawler = GoutteFacade::request('GET', $pageUrl); + $client = new Client(); + $crawler = $client->request('GET', $pageUrl); $crawl_arr = $crawler->filter('.classnameBLog'); if ($crawl_arr->count() === 0) { @@ -69,7 +70,8 @@ public function handle() public function scrapeData($url, $title, $image, $summary, $categoryId, $lang) { - $crawler = GoutteFacade::request('GET', $url); + $client = new Client(); + $crawler =$client->request('GET', $url); $content = $this->crawlData_html('#main .post', $crawler); $check = Post::all();