Mihaaru scraper support

This commit is contained in:
2020-08-10 03:21:56 +05:00
parent 5af5f75175
commit fd2fc06115
4 changed files with 30 additions and 6 deletions

View File

@@ -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"],
]);
}
}
}