2025-06-29 21:33:18 +02:00
|
|
|
<?php
|
|
|
|
|
|
2025-08-15 16:39:18 +02:00
|
|
|
namespace Domains\Article\Parsers\Vrt;
|
2025-06-29 21:33:18 +02:00
|
|
|
|
|
|
|
|
class VrtHomepageParser
|
|
|
|
|
{
|
2025-07-07 00:51:32 +02:00
|
|
|
/**
|
|
|
|
|
* @return array<int, string>
|
|
|
|
|
*/
|
2025-06-29 21:33:18 +02:00
|
|
|
public static function extractArticleUrls(string $html): array
|
|
|
|
|
{
|
|
|
|
|
// Extract article links using regex
|
|
|
|
|
preg_match_all('/href="(\/vrtnws\/en\/\d{4}\/\d{2}\/\d{2}\/[^"]+)"/', $html, $matches);
|
|
|
|
|
|
2025-07-06 20:45:40 +02:00
|
|
|
$urls = collect($matches[1])
|
2025-06-29 21:33:18 +02:00
|
|
|
->unique()
|
|
|
|
|
->map(fn ($path) => 'https://www.vrt.be' . $path)
|
|
|
|
|
->toArray();
|
|
|
|
|
|
|
|
|
|
return $urls;
|
|
|
|
|
}
|
|
|
|
|
}
|