This commit is contained in:
Mohamed jinas
2024-01-06 23:48:58 +05:00
parent a49c18229a
commit c8d8ccaebb
3 changed files with 37 additions and 21 deletions

View File

@@ -70,14 +70,14 @@ class Kernel extends ConsoleKernel
$schedule->command('scrape:hama')->everyFiveMinutes()
->pingOnSuccess(env('APP_URL') . "/api/ping/hama");
$schedule->command('scrape:raajjemv')->everyFiveMinutes()
->pingOnSuccess(env('APP_URL') . "/api/ping/raajjemv");
// $schedule->command('scrape:raajjemv')->everyFiveMinutes()
// ->pingOnSuccess(env('APP_URL') . "/api/ping/raajjemv");
$schedule->command('scrape:funadhoo-times')->everyFiveMinutes()
->pingOnSuccess(env('APP_URL') . "/api/ping/funadhoo-times");
// $schedule->command('scrape:funadhoo-times')->everyFiveMinutes()
// ->pingOnSuccess(env('APP_URL') . "/api/ping/funadhoo-times");
$schedule->command('scrape:zaviyani')->everyFiveMinutes()
->pingOnSuccess(env('APP_URL') . "/api/ping/zaviyani");
// $schedule->command('scrape:zaviyani')->everyFiveMinutes()
// ->pingOnSuccess(env('APP_URL') . "/api/ping/zaviyani");
$schedule->command('scrape:jazeera')->everyFiveMinutes()
->pingOnSuccess(env('APP_URL') . "/api/ping/jazeera");

View File

@@ -19,7 +19,15 @@ class SourcesAPIController extends Controller
public function index()
{
return Cache::remember('sources.index', 300, function () {
return SourceResource::collection(Source::all());
return SourceResource::collection(Source::whereNotIn('slug',[
'mihaaru',
'hama',
'zaviyani',
'funadhoo-times',
'psm',
'raajjemv',
'voice'
])->get());
});
}

View File

@@ -1,5 +1,4 @@
<?php
namespace App\Services\Feeds;
use Goutte\Client;
@@ -12,29 +11,38 @@ class RaajjeMvFeed implements Feed
{
$this->client = new Client();
}
/**
* Get all the latest news
* Get all the latest news from the 'އެންމެ ފަސް' section
*
* @return array
*/
public function get(): array
{
$crawler = $this->client->request('GET', "https://raajje.mv/");
$feeds = [];
$articles = $crawler->filter('div[v-if*="homepage.emme_fas"] article-grid')->first()->attr(':collection');
// Find the 'އެންމެ ފަސް' section
$articlesContainer = $crawler->filter('.waheed')->each(function ($node) {
// Ensure we are in the right section
if (strpos($node->text(), 'އެންމެ ފަސް') !== false) {
return $node->filter('a')->each(function ($articleNode) {
$link = $articleNode->attr('href');
$title = trim($articleNode->filter('div.leading-relaxed')->text());
$date = trim($articleNode->filter('div.mt-3.text-sm')->text());
$raw_response = json_decode(html_entity_decode($articles), true);
foreach($raw_response as $response)
{
$feeds[] = [
"title" => $response["heading"],
"link" => "https://raajje.mv/".$response["id"],
"date" => $response["approved_date"]
];
}
return [
"title" => $title,
"link" => "https://raajje.mv" . $link,
"date" => $date
];
});
}
});
return $feeds;
// Remove null values and flatten the array
$articlesContainer = array_filter($articlesContainer);
return !empty($articlesContainer) ? array_merge(...$articlesContainer) : [];
}
}