Skip to content

Commit

Permalink
update update goutte and goutte-facade
Browse files Browse the repository at this point in the history
  • Loading branch information
giauphan committed Mar 14, 2024
1 parent 7e728fb commit df8f0e6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"giauphan/goutte": "^1.1",
"guzzlehttp/guzzle": "^7.2",
"illuminate/console": "*",
"illuminate/database": "*"
"illuminate/database": "*",
"giauphan/goutte-facade": "^1.0"
}
}
8 changes: 3 additions & 5 deletions src/Commands/CrawlBlogData.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
use Giauphan\CrawlBlog\Models\CategoryBlog;
use Giauphan\CrawlBlog\Models\Post;
use Illuminate\Console\Command;
use Giauphan\Client;
use Illuminate\Support\Str;
use Carbon\Carbon;
use Giauphan\Goutte\GoutteFacade;
use Symfony\Component\DomCrawler\Crawler;

class CrawlBlogData extends Command
Expand All @@ -30,8 +30,7 @@ public function handle()
$category = CategoryBlog::firstOrCreate(['name' => $categoryName], ['slug' => Str::slug($categoryName)]);
$categoryId = $category->id;
do {
$client = new Client();
$crawler = $client->request('GET', $pageUrl);
$crawler = GoutteFacade::request('GET', $pageUrl);

$crawl_arr = $crawler->filter('.classnameBLog');
if ($crawl_arr->count() === 0) {
Expand Down Expand Up @@ -70,8 +69,7 @@ public function handle()

public function scrapeData($url, $title, $image, $summary, $categoryId, $lang)
{
$client = new Client();
$crawler =$client->request('GET', $url);
$crawler = GoutteFacade::request('GET', $url);
$content = $this->crawlData_html('#main .post', $crawler);
$check = Post::all();

Expand Down

0 comments on commit df8f0e6

Please sign in to comment.