0
  • I want to get some URLs of images in Js/HTML: img class="img-responsive" id="Q72D2600000-MDYI" src="https://s7d5.scene7.com/is/image/Guess/Q72D2600000-MDYI?$2014_G_xxlarge$" alt="Q72D2600000-MDYI" />

  • Looking for solution that will detect image url. So the output will be: https://s7d5.scene7.com/is/image/Guess/Q72D2600000-MDYI?$2014_G_xxlarge$

Rong Rêu
  • 21
  • 1

1 Answers1

0

The below code may be helpfull

$html = '<img class="img-responsive" id="Q72D2600000-MDYI" src="https://s7d5.scene7.com/is/image/Guess/Q72D2600000-MDYI?$2014_G_xxlarge$" alt="Q72D2600000-MDYI" />';
preg_match('/<img\s.*?\bsrc="(.*?)".*?>/si', $html, $matches);

$image_src = $matches[1];

echo $image_src;

Output

https://s7d5.scene7.com/is/image/Guess/Q72D2600000-MDYI?$2014_G_xxlarge$
Ravinder Reddy
  • 3,869
  • 1
  • 13
  • 22
  • Thank you very much. I am using a Scrapebox 2.0 tool. I need one that regex to get the image URL from that source code. Is there a solution for me? Simply a reasonable regex code – Rong Rêu Jun 07 '17 at 18:43