39 lines
896 B
PHP
39 lines
896 B
PHP
<?php
|
|
namespace App\Services\Feeds;
|
|
|
|
use Goutte\Client;
|
|
|
|
class ZaviyaniFeed 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://zaviyani.mv/");
|
|
|
|
$feeds = [];
|
|
$crawler->filter('div[class*="jeg_vc_content"] article')->each(function ($node) use (&$feeds) {
|
|
|
|
|
|
$feeds[] = [
|
|
"title" => $node->filter('.jeg_post_title')->text(),
|
|
"link" => $node->filter('.jeg_post_title a')->attr('href'),
|
|
"date" => str_replace("-","",$node->filter('.jeg_meta_date a')->first()->text())
|
|
];
|
|
|
|
});
|
|
|
|
return array_slice($feeds,0,24);
|
|
|
|
}
|
|
} |