Feed refactor
This commit is contained in:
@@ -24,33 +24,23 @@ class AvasFeed implements Feed
|
|||||||
$crawler = $this->client->request('GET', "https://avas.mv/");
|
$crawler = $this->client->request('GET', "https://avas.mv/");
|
||||||
|
|
||||||
$feeds = [];
|
$feeds = [];
|
||||||
$first_batch_dates = [];
|
|
||||||
$second_batch_dates = [];
|
|
||||||
|
|
||||||
$crawler->filter('div[class*="flex rtl -mx-4 flex-wrap md:px-0"] div[class*="w-full md:w-1/3 px-4 mb-7"] div a timeago')->each(function ($node) use (&$first_batch_dates) {
|
|
||||||
$first_batch_dates[] = $node->attr('datetime');
|
|
||||||
});
|
|
||||||
|
|
||||||
$crawler->filter('div[class*="flex md:-mx-4 flex-wrap md:px-0"] div[class*="w-full md:w-1/5 px-4 mb-8"] div a timeago')->each(function ($node) use (&$second_batch_dates) {
|
|
||||||
$second_batch_dates[] = $node->attr('datetime');
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
$crawler->filter('div[class*="flex rtl -mx-4 flex-wrap md:px-0"] div[class*="w-full md:w-1/3 px-4 mb-7"] div a')->each(function ($node, $i) use (&$feeds, $first_batch_dates) {
|
$crawler->filter('div[class*="flex rtl -mx-4 flex-wrap md:px-0"] div[class*="w-full md:w-1/3 px-4 mb-7"] div a')->each(function ($node) use (&$feeds) {
|
||||||
$feeds[] = [
|
$feeds[] = [
|
||||||
"title" => trim($node->text()),
|
"title" => trim($node->text()),
|
||||||
"link" => "https://avas.mv" . $node->attr('href'),
|
"link" => "https://avas.mv" . $node->attr('href'),
|
||||||
"date" => Carbon::parse($first_batch_dates[$i])->format("Y-m-d H:i:s")
|
"date" => Carbon::parse($node->filter('timeago')->first()->attr('datetime'))->format("Y-m-d H:i:s")
|
||||||
|
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
$crawler->filter('div[class*="flex md:-mx-4 flex-wrap md:px-0"] div[class*="w-full md:w-1/5 px-4 mb-8"] div a')->each(function ($node, $i) use (&$feeds, $second_batch_dates) {
|
$crawler->filter('div[class*="flex md:-mx-4 flex-wrap md:px-0"] div[class*="w-full md:w-1/5 px-4 mb-8"] div a')->each(function ($node) use (&$feeds) {
|
||||||
$feeds[] = [
|
$feeds[] = [
|
||||||
"title" => trim($node->text()),
|
"title" => trim($node->text()),
|
||||||
"link" => "https://avas.mv" . $node->attr('href'),
|
"link" => "https://avas.mv" . $node->attr('href'),
|
||||||
"date" => Carbon::parse($second_batch_dates[$i])->format("Y-m-d H:i:s")
|
"date" => Carbon::parse($node->filter('timeago')->first()->attr('datetime'))->format("Y-m-d H:i:s")
|
||||||
|
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user