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

@@ -0,0 +1,39 @@
<?php
namespace App\Services\Feeds;
use Goutte\Client;
class ThiladhunFeed implements Feed
{
protected $client;
public function __construct()
{
$this->client = new Client();
}
/**
* Get all the latest news
*
* @return array
*/
public function get() : array
{
$crawler = $this->client->request('GET', "https://www.thiladhun.com");
$feeds = [];
$crawler->filter('div[class*="posts-listing posts-list"] article')->each(function ($node) use (&$feeds) {
$feeds[] = [
"title" => $node->filter('.post__title a')->text(),
"link" => $node->filter('.post__title a')->attr('href'),
"date" => $node->filter('time')->first()->attr('datetime')
];
});
return $feeds;
}
}