Update existing and thiladhun date fix
This commit is contained in:
@@ -48,7 +48,7 @@ class ScrapeAdduLiveCommand extends Command
|
|||||||
foreach ($articles as $article) {
|
foreach ($articles as $article) {
|
||||||
|
|
||||||
// Attach the relationship between source and article and return the curren article instance
|
// 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"],
|
"title" => $article["title"],
|
||||||
"url" => $article["url"],
|
"url" => $article["url"],
|
||||||
|
@@ -47,7 +47,7 @@ class ScrapeAvasCommand extends Command
|
|||||||
foreach ($articles as $article) {
|
foreach ($articles as $article) {
|
||||||
|
|
||||||
// Attach the relationship between source and article and return the curren article instance
|
// 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"],
|
"title" => $article["title"],
|
||||||
"url" => $article["url"],
|
"url" => $article["url"],
|
||||||
|
@@ -47,7 +47,7 @@ class ScrapeDhenCommand extends Command
|
|||||||
foreach ($articles as $article) {
|
foreach ($articles as $article) {
|
||||||
|
|
||||||
// Attach the relationship between source and article and return the curren article instance
|
// 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"],
|
"title" => $article["title"],
|
||||||
"url" => $article["url"],
|
"url" => $article["url"],
|
||||||
|
@@ -47,7 +47,7 @@ class ScrapeMihaaruCommand extends Command
|
|||||||
foreach ($articles as $article) {
|
foreach ($articles as $article) {
|
||||||
|
|
||||||
// Attach the relationship between source and article and return the curren article instance
|
// 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"],
|
"title" => $article["title"],
|
||||||
"url" => $article["url"],
|
"url" => $article["url"],
|
||||||
|
@@ -48,7 +48,7 @@ class ScrapeSunCommand extends Command
|
|||||||
foreach ($articles as $article) {
|
foreach ($articles as $article) {
|
||||||
|
|
||||||
// Attach the relationship between source and article and return the curren article instance
|
// Attach the relationship between source and article and return the curren article instance
|
||||||
$articleModel = $source->articles()->firstOrCreate(
|
$articleModel = $source->articles()->updateOrCreate(
|
||||||
["guid" => $article["guid"]],
|
["guid" => $article["guid"]],
|
||||||
[
|
[
|
||||||
"title" => $article["title"],
|
"title" => $article["title"],
|
||||||
|
@@ -48,7 +48,7 @@ class ScrapeThePressCommand extends Command
|
|||||||
foreach ($articles as $article) {
|
foreach ($articles as $article) {
|
||||||
|
|
||||||
// Attach the relationship between source and article and return the curren article instance
|
// 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"],
|
"title" => $article["title"],
|
||||||
"url" => $article["url"],
|
"url" => $article["url"],
|
||||||
|
@@ -48,7 +48,7 @@ class ScrapeThiladhunCommand extends Command
|
|||||||
foreach ($articles as $article) {
|
foreach ($articles as $article) {
|
||||||
|
|
||||||
// Attach the relationship between source and article and return the curren article instance
|
// Attach the relationship between source and article and return the curren article instance
|
||||||
$articleModel = $source->articles()->firstOrCreate(
|
$articleModel = $source->articles()->updateOrCreate(
|
||||||
["guid" => $article["guid"]],
|
["guid" => $article["guid"]],
|
||||||
[
|
[
|
||||||
"title" => $article["title"],
|
"title" => $article["title"],
|
||||||
|
@@ -48,7 +48,7 @@ class ScrapeVoiceCommand extends Command
|
|||||||
foreach ($articles as $article) {
|
foreach ($articles as $article) {
|
||||||
|
|
||||||
// Attach the relationship between source and article and return the curren article instance
|
// 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"],
|
"title" => $article["title"],
|
||||||
"url" => $article["url"],
|
"url" => $article["url"],
|
||||||
|
@@ -33,7 +33,7 @@ class ThiladhunScraper
|
|||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function extract($url, $date = null, $guid = null)
|
public function extract($url)
|
||||||
{
|
{
|
||||||
$this->guid = str_replace('https://thiladhun.com/', '', $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')),
|
'og_title' => str_replace(" | Thiladhun", "", $crawler->filter('title')->first()->text('content')),
|
||||||
'image' => $this->image,
|
'image' => $this->image,
|
||||||
'content' => $this->content,
|
'content' => $this->content,
|
||||||
'date' => $date,
|
'date' => $crawler->filter('.entry-meta time')->attr('datetime'),
|
||||||
'url' => $url,
|
'url' => $url,
|
||||||
'author' => $this->author,
|
'author' => $this->author,
|
||||||
'guid' => $this->guid,
|
'guid' => $this->guid,
|
||||||
|
@@ -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.
|
//Looping through the articles and scraping and while scraping it creates a new instance of the scraper.
|
||||||
foreach ($articles as $article) {
|
foreach ($articles as $article) {
|
||||||
$link = $article['link'];
|
$link = $article['link'];
|
||||||
$date = $article['pubDate'];
|
$articlesitems[] = (new ThiladhunScraper)->extract($link);
|
||||||
$guid = $article['guid'];
|
|
||||||
$articlesitems[] = (new ThiladhunScraper)->extract($link, $date, $guid);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $articlesitems;
|
return $articlesitems;
|
||||||
|
Reference in New Issue
Block a user