41 lines
1.1 KiB
PHP
41 lines
1.1 KiB
PHP
<?php
|
|
namespace App\Services\Feeds;
|
|
|
|
use Goutte\Client;
|
|
|
|
class ThiladhunFeed 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://www.thiladhun.com");
|
|
|
|
$feeds = [];
|
|
// Assuming 'ފަހުގެ' is a unique identifier for the section of interest
|
|
$crawler->filter('.elementor-element:contains("ފަހުގެ")')->nextAll('.elementor-post')->each(function ($node) use (&$feeds) {
|
|
$title = $node->filter('.elementor-heading-title a')->count() ? $node->filter('.elementor-heading-title a')->text() : null;
|
|
$link = $node->filter('.elementor-heading-title a')->count() ? $node->filter('.elementor-heading-title a')->attr('href') : null;
|
|
|
|
if ($title && $link) {
|
|
$feeds[] = [
|
|
"title" => $title,
|
|
"link" => $link,
|
|
];
|
|
}
|
|
});
|
|
|
|
return $feeds;
|
|
}
|
|
|
|
}
|