Dhiyares intergration
This commit is contained in:
39
app/Services/Feeds/DhiyaresFeed.php
Normal file
39
app/Services/Feeds/DhiyaresFeed.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
namespace App\Services\Feeds;
|
||||
|
||||
use Goutte\Client;
|
||||
|
||||
class DhiyaresFeed 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://dhiyares.com");
|
||||
|
||||
$feeds = [];
|
||||
$crawler->filter('.recent-list')->each(function ($node) use (&$feeds) {
|
||||
|
||||
|
||||
$feeds[] = [
|
||||
"title" => $node->filter('h3')->text(),
|
||||
"link" => $node->filter('a')->attr('href'),
|
||||
"date" => $node->filter('time-comment')->first()->attr('datetime')
|
||||
];
|
||||
|
||||
});
|
||||
|
||||
return $feeds;
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user