With the help of simple_html_dom I got all the data that I need, but I can't get a link to the picture from here.

<span itemprop="image" content="https://lh3.ggpht.com/pvG5fFwMsvPcAX8-IojHOBdNHdmrCtr6asadB4D5GoWfZMrXGtNXYQUJT-JMVk5zcb4=w124" /> 

either from here:

 > <div class="doc-banner-icon"><img > itemprop="image"src="https://lh3.ggpht.com/pvG5fFwMsvPcAX8-IojHOBdNHdmrCtr6asadB4D5GoWfZMrXGtNXYQUJT-JMVk5zcb4=w124"/></div> 
  • Specify what it means "does not work"? Maybe bring your code if it is not secret? (Only not all, only the necessary fragment.) - VladD
  • I tried to take in different ways:> $ link = $ html-> find ('img', 0); > $ link = $ html-> find ('div [class = doc-banner-icon] img', 0); > $ link = $ html-> find ('img [itemprop = image]', 0); but not one of them gave me any links - Zhuzhu
  • And what is done to search for pictures and what exactly does not work? For example, how to find all span with itemprop - understandable? - user6550 February
  • I did not look for all the problems with the ITEMPROP, I immediately looked for the one with which the ITEMPROP = image - I LIVE
  • > $ link = $ html-> find ('img [itemprop = image]', 0); What's this? - user6550 February


1 answer 1

Stand still. Which returns $link=$html->find('img',0); ? The very first picture. And you need to go around all the pictures. Do honestly:

 foreach($html->find('img') as $element) { if (isset($element->itemprop)) // ... } 

And by the way, what's in your $link ?

  • I throw a link to the image into it. and then how to get the content field value from the element? (I apologize for newcomer questions) - I LIVE
  • Uh ... Link is <a href="url">content</a> ? Try $link->innertext . - VladD
  • everything. figured out - ZhUZHU
  • @ Yevhen Formanyuk: please! - VladD