Thiladhun switch to virtual feed
This commit is contained in:
@@ -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;
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user