Refactor of the feed
This commit is contained in:
@@ -23,18 +23,12 @@ class MiadhuFeed implements Feed
|
||||
$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) {
|
||||
$crawler->filter('.middle div[class*="col-md-3 col-6 news-block"]')->each(function ($node) use (&$feeds) {
|
||||
$feeds[] = [
|
||||
"title" => $node->text(),
|
||||
"link" => $node->attr('href'),
|
||||
"date" => $dates[$i]
|
||||
"title" => $node->filter('h2 a')->first()->text(),
|
||||
"link" => $node->filter('h2 a')->first()->attr('href'),
|
||||
"date" => $node->filter('em')->first()->text()
|
||||
];
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user