1

I want to extract the information on this page using a script PHP Simple HTML DOM, Here is part of the code I wrote:


$html = file_get_html('https://www.digikala.com/product/dkp-7475119/');
foreach ($html->find('p.color-900') as $e) {
            $color = $e->outertext;
            echo  $color ;
            break;
        }

But unfortunately the output I receive is Undefined variable

h1h2
  • 85
  • 2
  • 11

1 Answers1

0

As @Kevin Y said in his comment, you are searching for something that isn't there... yet.

Visit view-source:https://www.digikala.com/product/dkp-7475119/ and search for <p>

The page hasn't loaded the extra elements onto it yet like the <p> tag you are looking for. This is likely because the page is loading them in after-the-fact using JavaScript so you will need to find a way to get the html after the page has loaded its contents that are added in later.

Liam Pillay
  • 592
  • 1
  • 4
  • 19