40 lines
837 B
PHP
40 lines
837 B
PHP
<?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;
|
|
|
|
}
|
|
}
|