file_get_contents data can not be scarped

This is the code

$link = "https://www.apple.com/au/search/medication-management?src=globalnav";
$str = file_get_contents($link);
//$str= '<a href="https://apps.apple.com/au/app/medicinewise-manage-medicine/id777483494" class="rf-serp-productname-link">MedicineWise: Manage Medicine</a>';
$pattern="/<a href=".+" class="rf-serp-productname-link">/";
if(preg_match_all($pattern, $str, $matches)) {
  print_r($matches);
}

Inisde $str there is

`<a href="https://apps.apple.com/au/app/medicinewise-manage-medicine/id777483494" class="rf-serp-productname-link">MedicineWise: Manage Medicine</a>

So expected output is

Array
(
    [0] => Array
        (
            [0] => <a href="https://apps.apple.com/au/app/medadvisor-medications-manager/id626138245" class="rf-serp-productname-link">
        )

)

I get this ouput when I define $str manually. But when I get content from the link I am not getting desired result.