Zaviyani news intergration

This commit is contained in:
2021-01-11 13:46:06 +05:00
parent 31404d2f48
commit bb5602f911
5 changed files with 202 additions and 0 deletions

View 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);
}
}