22 lines
No EOL
515 B
PHP
22 lines
No EOL
515 B
PHP
<?php
|
|
|
|
namespace Domains\Article\Parsers\Vrt;
|
|
|
|
class VrtHomepageParser
|
|
{
|
|
/**
|
|
* @return array<int, string>
|
|
*/
|
|
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);
|
|
|
|
$urls = collect($matches[1])
|
|
->unique()
|
|
->map(fn ($path) => 'https://www.vrt.be' . $path)
|
|
->toArray();
|
|
|
|
return $urls;
|
|
}
|
|
} |