Hama news intergration

This commit is contained in:
2020-10-13 23:01:02 +05:00
parent be034116c5
commit fff50a36ac
6 changed files with 205 additions and 2 deletions

View File

@@ -0,0 +1,39 @@
<?php
namespace App\Services\Feeds;
use Goutte\Client;
class HamaFeed 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://hama.mv/");
$feeds = [];
$crawler->filter('div[id*="latest"] div[class*="col-md-3 col-6"] a')->each(function ($node) use (&$feeds) {
$feeds[] = [
"title" => $node->filter('h5')->first()->text(),
"link" => $node->attr('href'),
"date" => $node->filter('.datetime')->first()->text()
];
});
return $feeds;
}
}