Zaviyani news intergration
This commit is contained in:
39
app/Services/Feeds/ZaviyaniFeed.php
Normal file
39
app/Services/Feeds/ZaviyaniFeed.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?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);
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user