39 lines
825 B
PHP
39 lines
825 B
PHP
<?php
|
|
|
|
namespace App\Services\Feeds;
|
|
|
|
use Goutte\Client;
|
|
|
|
class MiadhuFeed implements Feed
|
|
{
|
|
protected $client;
|
|
|
|
public function __construct()
|
|
{
|
|
$this->client = new Client();
|
|
}
|
|
/**
|
|
* Return the latest articles from avas
|
|
*
|
|
* @return array
|
|
*/
|
|
public function get(): array
|
|
{
|
|
|
|
$crawler = $this->client->request('GET', "https://miadhu.mv");
|
|
|
|
$feeds = [];
|
|
|
|
$crawler->filter('.middle div[class*="col-md-3 col-6 news-block"]')->each(function ($node) use (&$feeds) {
|
|
$feeds[] = [
|
|
"title" => $node->filter('h2 a')->first()->text(),
|
|
"link" => $node->filter('h2 a')->first()->attr('href'),
|
|
"date" => $node->filter('em')->first()->text()
|
|
];
|
|
});
|
|
|
|
|
|
return $feeds;
|
|
}
|
|
}
|