Refactor of the feed

This commit is contained in:
2020-10-13 22:52:55 +05:00
parent 4015fa9221
commit be034116c5

View File

@@ -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()
];
});