Mihaaru scraper support
This commit is contained in:
@@ -2,7 +2,9 @@
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Source;
|
||||
use Illuminate\Console\Command;
|
||||
use App\Services\MihaaruService;
|
||||
|
||||
class ScrapeMihaaruCommand extends Command
|
||||
{
|
||||
@@ -37,6 +39,25 @@ class ScrapeMihaaruCommand extends Command
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
return 0;
|
||||
$source = Source::where('slug', 'mihaaru')->first();
|
||||
|
||||
$articles = (new MihaaruService)->scrape();
|
||||
|
||||
foreach($articles as $article)
|
||||
{
|
||||
$source->articles()->firstOrCreate([
|
||||
"title" => $article["title"],
|
||||
"url" => $article["url"],
|
||||
"author" => $article["author"],
|
||||
"featured_image" => $article["image"],
|
||||
"body" => $article["content"],
|
||||
"guid" => $article["guid"],
|
||||
"published_date" => $article["date"],
|
||||
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Console;
|
||||
|
||||
use App\Console\Commands\ScrapeMihaaruCommand;
|
||||
use Illuminate\Console\Scheduling\Schedule;
|
||||
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
||||
|
||||
@@ -13,7 +14,7 @@ class Kernel extends ConsoleKernel
|
||||
* @var array
|
||||
*/
|
||||
protected $commands = [
|
||||
//
|
||||
ScrapeMihaaruCommand::class
|
||||
];
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user