Betmen35 Laravel'de böyle bir özellik yok. Bunun için DOMDocument ve DOMXPath kullanacaksınız. Mesela çekilen html içindeki tüm resimlerin src değerlerini almak istersek:
// Kodlamadaki hataların size yansımaması için susturuyoruz:
libxml_use_internal_errors(true);
$response = Http::get('https://stock.adobe.com/ee/search?k=kitten+in+box');
$foundImages = [];
if($response->ok()) {
$dom = new DOMDocument();
$dom->loadHTML($response->body());
$xpath = new DOMXPath($dom);
// xpath kullanarak neyi seçeceğimizi belirtiyoruz
// https://devhints.io/xpath adresinden bilgi alabilirsiniz.
$images = $xpath->query('//img/@src');
foreach($images as $image){
$path = pathinfo($image->nodeValue);
if(in_array(strtolower($path['extension']), ['jpg', 'jpeg'])) {
$foundImages[] = $image->nodeValue;
}
}
}
return $foundImages;
[
"https://t4.ftcdn.net/jpg/01/25/65/31/360_F_125653197_cDFZ7khagSvuiMDfeFXeNq1PyqLt5M5Y.jpg",
"https://t4.ftcdn.net/jpg/00/84/33/07/360_F_84330731_iQ5d6tZnQDON0u3KFXYCefeWeLJ5ypaX.jpg",
"https://t3.ftcdn.net/jpg/02/92/42/22/360_F_292422229_gxpqjun3DvP1lmk5ZKfvSvc5uk9M68Gc.jpg",
"https://t4.ftcdn.net/jpg/00/67/73/07/360_F_67730753_88Dl98pfoennXzXWTEGQcJdVyuAqSE3R.jpg",
"https://t4.ftcdn.net/jpg/00/61/92/45/360_F_61924518_6pfPTJR5qKW0k6e8Z9W4sLJ2mT98NcCK.jpg",
"https://t4.ftcdn.net/jpg/01/71/31/61/360_F_171316190_VxGH7cB9PGat66mIBYICNG6UmoXXNvbi.jpg",
"https://t4.ftcdn.net/jpg/02/44/42/63/360_F_244426322_SxakzZucIY776TaVZOdDj8lug4QIWOAo.jpg",
"https://t4.ftcdn.net/jpg/03/76/58/43/360_F_376584302_f0IgxpnvU5xtQHbbQ7XXwZMvCQ1BEW5j.jpg",
"https://t3.ftcdn.net/jpg/00/35/33/24/360_F_35332498_NjNIpXbwCLl322oAUAeXhlGzSCMD2jSG.jpg",
"https://t3.ftcdn.net/jpg/05/09/67/28/360_F_509672878_UV14MLbimULaYwUzp7bL2WuD0gzy7hIH.jpg",
"https://t4.ftcdn.net/jpg/03/82/45/71/360_F_382457148_GG0sNMT1Hg44oRSFcvuo0Z08bkJN9yxF.jpg",
"https://t3.ftcdn.net/jpg/00/20/77/58/360_F_20775886_ZmQSquOa8HXBu6BAt7N0lFCJv9fB4qDU.jpg",
"https://t3.ftcdn.net/jpg/02/80/98/74/360_F_280987457_ZfPn7NgedtTer2ojJ01TBXMi1jahTkRt.jpg",
"https://t4.ftcdn.net/jpg/00/54/06/55/360_F_54065510_cx5a1BNay89l52RdIzH1WKtjh7eyS9Uu.jpg",
"https://t4.ftcdn.net/jpg/01/29/28/97/360_F_129289798_GTsapa9ugfLPihVFVycph8HXdP778ygE.jpg",
"https://t3.ftcdn.net/jpg/03/02/05/06/360_F_302050655_b4kXOwiSpCCDAP79htcQIVpZkd4YYTBz.jpg",
"https://t4.ftcdn.net/jpg/00/21/68/13/360_F_21681345_TqNJtUMzG3fikmiD52ViF7Z15YDKVdPp.jpg",
"https://t3.ftcdn.net/jpg/01/23/77/54/360_F_123775442_H3E87iL6XzTkknCPsHFby6cxNMF0i1jp.jpg",
"https://t3.ftcdn.net/jpg/02/81/60/08/360_F_281600844_78trQm8dwS8FUDnJGqpUka7ZLQRKxqDv.jpg",
"https://t3.ftcdn.net/jpg/00/62/44/34/360_F_62443465_wDFdIB8kmsiDoL3BB1ylaBBAMaySBGRy.jpg",
"https://t3.ftcdn.net/jpg/02/97/70/66/360_F_297706692_phbzydqzk6ooUoADH2hYQi9DpR311Ypg.jpg",
"https://t3.ftcdn.net/jpg/00/92/56/80/360_F_92568007_GSQ9KPqWBpwDc2qhxTVfrImsWa8Bboeh.jpg",
"https://t4.ftcdn.net/jpg/01/72/76/69/360_F_172766975_oPF4oZYINIRXxlk6bL2VJ8mIuBe0Katy.jpg",
"https://t4.ftcdn.net/jpg/00/83/50/29/360_F_83502915_xre8ke8L0aHv6sGGI0YPBBMeo7eKt46h.jpg",
"https://t4.ftcdn.net/jpg/00/76/36/01/360_F_76360198_7FnIPQYkz4RP1lKZyZU2NvsiHX34RGIO.jpg",
]
Buraları inceleyin:
https://www.php.net/manual/tr/class.domdocument.php
https://www.php.net/manual/tr/class.domxpath.php
https://devhints.io/xpath
Ayrıca şunu da kullanabilirsiniz:
https://symfony.com/doc/current/components/dom_crawler.html