Thiladhun switch to virtual feed

This commit is contained in:
2021-02-05 03:58:14 +05:00
parent d33c727b68
commit 8ea594723f
3 changed files with 45 additions and 8 deletions

View File

@@ -2,6 +2,7 @@
namespace App\Services;
use App\Services\Feeds\ThiladhunFeed;
use App\Services\Scrapers\ThiladhunScraper;
class ThiladhunService extends Client
@@ -14,13 +15,12 @@ class ThiladhunService extends Client
public function scrape(): array
{
//Return only the rss that contains "news" keyboard in its url
$articles = $this->get("https://thiladhun.com/feed")["channel"]["item"];
$articles = (new ThiladhunFeed)->get();
$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 ThiladhunScraper)->extract($link);
$articlesitems[] = (new ThiladhunScraper)->extract($article["link"], $article["date"]);
}
return $articlesitems;