Psm Support
This commit is contained in:
29
app/Services/PsmService.php
Normal file
29
app/Services/PsmService.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Services\Scrapers\PsmScraper;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class PsmService extends Client
|
||||
{
|
||||
/**
|
||||
* Scrap all the rss articles from mihaaru
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function scrape(): array
|
||||
{
|
||||
$articles = $this->get("https://www.psmnews.mv/feed")["entry"];
|
||||
|
||||
$articlesitems = [];
|
||||
//Looping through the articles and scraping and while scraping it creates a new instance of the scraper.
|
||||
foreach ($articles as $article) {
|
||||
$link = $article['id'];
|
||||
$date = $article['updated'];
|
||||
$articlesitems[] = (new PsmScraper)->extract($link, $date);
|
||||
}
|
||||
|
||||
return $articlesitems;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user