fedi-feed-router/app/Services/Parsers/VrtHomepageParser.php
myrmidex 6784af2ff6
Some checks failed
CI / ci (push) Failing after 4m31s
25 - Fix all PHPStan errors and add mockery extension
2026-03-08 14:18:28 +01:00

22 lines
587 B
PHP

<?php
namespace App\Services\Parsers;
class VrtHomepageParser
{
/**
* @return array<int, string>
*/
public static function extractArticleUrls(string $html, string $language = 'en'): array
{
$escapedLanguage = preg_quote($language, '/');
preg_match_all('/href="(?:https:\/\/www\.vrt\.be)?(\/vrtnws\/'.$escapedLanguage.'\/\d{4}\/\d{2}\/\d{2}\/[^"]+)"/', $html, $matches);
$urls = collect($matches[1])
->unique()
->map(fn ($path) => 'https://www.vrt.be'.$path)
->toArray();
return $urls;
}
}