fedi-feed-router/app/Services/Parsers/VrtHomepageParser.php

22 lines
No EOL
508 B
PHP

<?php
namespace App\Services\Parsers;
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;
}
}