I use SimpleHTMLDOM to grab stuff from other web page but i have a problem how to just get urls inside of image ancor tag because that web page consists linking anchor tags as well as image anchor tags ! but i just want to get href value in side the image anchor tag !
<a href="I DO NOT NEED THIS VALUE"><a/>
<a href="I NEED THIS VALUE"><img src="xxxx"><a/>
but when call for the DOM its returns all the href URLs including linking anchor URLs ! I just need the URLs inside image anchor tag !
i use this code to call..
$hrefl = $html->find('a');
$count = 1;
for( $i = 0; $i < 50; $i++){
echo $hrefl[$count]->href;
$count++;
}
You need the href attribute of every link that contains an image tag. With xpath it’s quite simple:
You wrote that you use DOM, your code looks like written with simple html dom. That library is limited and nowadays not needed any longer because PHP has the
DOMDocumentandDOMXPathobjects. I think simple html DOM has no xpath,Demo