18 lines
451 B
PHP
18 lines
451 B
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace App\Services\Parsers;
|
||
|
|
|
||
|
|
class BelgaHomepageParser
|
||
|
|
{
|
||
|
|
public static function extractArticleUrls(string $html): array
|
||
|
|
{
|
||
|
|
preg_match_all('/href="https:\/\/www\.belganewsagency\.eu\/([a-z0-9-]+)"/', $html, $matches);
|
||
|
|
|
||
|
|
$urls = collect($matches[0] ?? [])
|
||
|
|
->unique()
|
||
|
|
->map(fn ($url) => str_replace('href="', '', str_replace('"', '', $url)))
|
||
|
|
->toArray();
|
||
|
|
|
||
|
|
return $urls;
|
||
|
|
}
|
||
|
|
}
|