The Press intergration

This commit is contained in:
2020-08-14 21:57:16 +05:00
parent 14858d5bfa
commit 2382583587
4 changed files with 165 additions and 0 deletions

View File

@@ -0,0 +1,30 @@
<?php
namespace App\Services;
use App\Services\Scrapers\ThePressScraper;
use Illuminate\Support\Str;
class ThePressService extends Client
{
/**
* Scrap all the rss articles from Press
*
* @return array
*/
public function scrape(): array
{
//Return only the rss that contains "news" keyboard in its url
$articles = $this->get("https://thepress.mv/rss")["channel"]["item"];
$articlesitems = [];
//Looping through the articles and scraping and while scraping it creates a new instance of the scraper.
foreach ($articles as $article) {
$link = $article['link'];
$articlesitems[] = (new ThePressScraper)->extract($link);
}
return $articlesitems;
}
}