Miadhu News Support

This commit is contained in:
2020-10-03 03:21:34 +05:00
parent 3b50c8058f
commit cf4e6267b6
5 changed files with 200 additions and 1 deletions

View File

@@ -0,0 +1,44 @@
<?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 = [];
$dates = [];
// scrape the dates for the articles
$crawler->filter('.middle div[class*="col-md-3 col-6 news-block"] em')->each(function ($node) use (&$dates) {
$dates[] = $node->text();
});
$crawler->filter('.middle div[class*="col-md-3 col-6 news-block"] h2 a')->each(function ($node, $i) use (&$feeds, $dates) {
$feeds[] = [
"title" => $node->text(),
"link" => $node->attr('href'),
"date" => $dates[$i]
];
});
return $feeds;
}
}