diff --git a/app/Console/Commands/ScrapeAdduLiveCommand.php b/app/Console/Commands/ScrapeAdduLiveCommand.php index 487e2e1..17e05ac 100644 --- a/app/Console/Commands/ScrapeAdduLiveCommand.php +++ b/app/Console/Commands/ScrapeAdduLiveCommand.php @@ -48,7 +48,7 @@ class ScrapeAdduLiveCommand extends Command foreach ($articles as $article) { // Attach the relationship between source and article and return the curren article instance - $articleModel = $source->articles()->firstOrCreate(["guid" => $article["guid"]], + $articleModel = $source->articles()->updateOrCreate(["guid" => $article["guid"]], [ "title" => $article["title"], "url" => $article["url"], diff --git a/app/Console/Commands/ScrapeAvasCommand.php b/app/Console/Commands/ScrapeAvasCommand.php index 8accc35..d90d6e1 100644 --- a/app/Console/Commands/ScrapeAvasCommand.php +++ b/app/Console/Commands/ScrapeAvasCommand.php @@ -47,7 +47,7 @@ class ScrapeAvasCommand extends Command foreach ($articles as $article) { // Attach the relationship between source and article and return the curren article instance - $articleModel = $source->articles()->firstOrCreate(["guid" => $article["guid"]], + $articleModel = $source->articles()->updateOrCreate(["guid" => $article["guid"]], [ "title" => $article["title"], "url" => $article["url"], diff --git a/app/Console/Commands/ScrapeDhenCommand.php b/app/Console/Commands/ScrapeDhenCommand.php index f8ae5e4..1d7a59f 100644 --- a/app/Console/Commands/ScrapeDhenCommand.php +++ b/app/Console/Commands/ScrapeDhenCommand.php @@ -47,7 +47,7 @@ class ScrapeDhenCommand extends Command foreach ($articles as $article) { // Attach the relationship between source and article and return the curren article instance - $articleModel = $source->articles()->firstOrCreate(["guid" => $article["guid"]], + $articleModel = $source->articles()->updateOrCreate(["guid" => $article["guid"]], [ "title" => $article["title"], "url" => $article["url"], diff --git a/app/Console/Commands/ScrapeMihaaruCommand.php b/app/Console/Commands/ScrapeMihaaruCommand.php index 0d40c00..24de073 100644 --- a/app/Console/Commands/ScrapeMihaaruCommand.php +++ b/app/Console/Commands/ScrapeMihaaruCommand.php @@ -47,7 +47,7 @@ class ScrapeMihaaruCommand extends Command foreach ($articles as $article) { // Attach the relationship between source and article and return the curren article instance - $articleModel = $source->articles()->firstOrCreate(["guid" => $article["guid"]], + $articleModel = $source->articles()->updateOrCreate(["guid" => $article["guid"]], [ "title" => $article["title"], "url" => $article["url"], diff --git a/app/Console/Commands/ScrapeSunCommand.php b/app/Console/Commands/ScrapeSunCommand.php index ada1d46..e1c025e 100644 --- a/app/Console/Commands/ScrapeSunCommand.php +++ b/app/Console/Commands/ScrapeSunCommand.php @@ -48,7 +48,7 @@ class ScrapeSunCommand extends Command foreach ($articles as $article) { // Attach the relationship between source and article and return the curren article instance - $articleModel = $source->articles()->firstOrCreate( + $articleModel = $source->articles()->updateOrCreate( ["guid" => $article["guid"]], [ "title" => $article["title"], diff --git a/app/Console/Commands/ScrapeThePressCommand.php b/app/Console/Commands/ScrapeThePressCommand.php index 15e82b3..cb04f90 100644 --- a/app/Console/Commands/ScrapeThePressCommand.php +++ b/app/Console/Commands/ScrapeThePressCommand.php @@ -48,7 +48,7 @@ class ScrapeThePressCommand extends Command foreach ($articles as $article) { // Attach the relationship between source and article and return the curren article instance - $articleModel = $source->articles()->firstOrCreate(["guid" => $article["guid"]], + $articleModel = $source->articles()->updateOrCreate(["guid" => $article["guid"]], [ "title" => $article["title"], "url" => $article["url"], diff --git a/app/Console/Commands/ScrapeThiladhunCommand.php b/app/Console/Commands/ScrapeThiladhunCommand.php index c7d86c4..f55d7ed 100644 --- a/app/Console/Commands/ScrapeThiladhunCommand.php +++ b/app/Console/Commands/ScrapeThiladhunCommand.php @@ -48,7 +48,7 @@ class ScrapeThiladhunCommand extends Command foreach ($articles as $article) { // Attach the relationship between source and article and return the curren article instance - $articleModel = $source->articles()->firstOrCreate( + $articleModel = $source->articles()->updateOrCreate( ["guid" => $article["guid"]], [ "title" => $article["title"], diff --git a/app/Console/Commands/ScrapeVoiceCommand.php b/app/Console/Commands/ScrapeVoiceCommand.php index c4394fe..80e3e97 100644 --- a/app/Console/Commands/ScrapeVoiceCommand.php +++ b/app/Console/Commands/ScrapeVoiceCommand.php @@ -48,7 +48,7 @@ class ScrapeVoiceCommand extends Command foreach ($articles as $article) { // Attach the relationship between source and article and return the curren article instance - $articleModel = $source->articles()->firstOrCreate(["guid" => $article["guid"]], + $articleModel = $source->articles()->updateOrCreate(["guid" => $article["guid"]], [ "title" => $article["title"], "url" => $article["url"], diff --git a/app/Services/Scrapers/ThiladhunScraper.php b/app/Services/Scrapers/ThiladhunScraper.php index 1c340c6..bd0217c 100644 --- a/app/Services/Scrapers/ThiladhunScraper.php +++ b/app/Services/Scrapers/ThiladhunScraper.php @@ -33,7 +33,7 @@ class ThiladhunScraper * * @return array */ - public function extract($url, $date = null, $guid = null) + public function extract($url) { $this->guid = str_replace('https://thiladhun.com/', '', $url); @@ -63,7 +63,7 @@ class ThiladhunScraper 'og_title' => str_replace(" | Thiladhun", "", $crawler->filter('title')->first()->text('content')), 'image' => $this->image, 'content' => $this->content, - 'date' => $date, + 'date' => $crawler->filter('.entry-meta time')->attr('datetime'), 'url' => $url, 'author' => $this->author, 'guid' => $this->guid, diff --git a/app/Services/ThiladhunService.php b/app/Services/ThiladhunService.php index bd69f5e..d0fd604 100644 --- a/app/Services/ThiladhunService.php +++ b/app/Services/ThiladhunService.php @@ -20,9 +20,7 @@ class ThiladhunService extends Client //Looping through the articles and scraping and while scraping it creates a new instance of the scraper. foreach ($articles as $article) { $link = $article['link']; - $date = $article['pubDate']; - $guid = $article['guid']; - $articlesitems[] = (new ThiladhunScraper)->extract($link, $date, $guid); + $articlesitems[] = (new ThiladhunScraper)->extract($link); } return $articlesitems;