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");
|
$crawler = $this->client->request('GET', "https://miadhu.mv");
|
||||||
|
|
||||||
$feeds = [];
|
$feeds = [];
|
||||||
$dates = [];
|
|
||||||
|
|
||||||
// scrape the dates for the articles
|
$crawler->filter('.middle div[class*="col-md-3 col-6 news-block"]')->each(function ($node) use (&$feeds) {
|
||||||
$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[] = [
|
$feeds[] = [
|
||||||
"title" => $node->text(),
|
"title" => $node->filter('h2 a')->first()->text(),
|
||||||
"link" => $node->attr('href'),
|
"link" => $node->filter('h2 a')->first()->attr('href'),
|
||||||
"date" => $dates[$i]
|
"date" => $node->filter('em')->first()->text()
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user