acctman Posted January 17, 2013 Share Posted January 17, 2013 Hi i'm using Simple HTML Dom to scrap a site page. I'm trying to grab the width value for each img src. Below is the html and php i've been using so far. <table> <tr> <th colspan="4"> <font size="3" color="#a74165">Interest Levels</font> </th> </tr> <tr> <td nowrap> <font size="2">MobileT</font> </td> <td><img src="http://pictures.domain.com/images/7.gif" alt="1 on a scale of 0-4" border="0" height="15" width="9"> </td> <td> </td> <td nowrap> <font size="2">MobileC</font> </td> <td> <img src="http://pictures.domain.com/images/7.gif" alt="3 on a scale of 0-4" border="0" height="15" width="27"> </td> </tr> <tr> <td nowrap> <font size="2">Moderate</font> </td> <td><img src="http://pictures.domain.com/images/7.gif" alt="3 on a scale of 0-4" border="0" height="15" width="27"> </td> <td> </td> <td nowrap> <font size="2">Males</font> </td> <td> </td> </tr> <tr> <td nowrap> <font size="2">Wild</font> </td> <td><img src="http://pictures.domain.com/images/7.gif" alt="3 on a scale of 0-4" border="0" height="15" width="27"> </td> <td> </td> <td nowrap> <font size="2">Females</font> </td> <td> <img src="http://pictures.domain.com/images/7.gif" alt="4 on a scale of 0-4" border="0" height="15" width="36"> </td> </tr> </table> include('simple_html_dom.php'); $html = new simple_html_dom(); $html = file_get_html('http://dev.domain.com/'); $element = $html->find("td font[size=3]", 0); echo $element-> plaintext . '<br>'; $element = $html->find("font", 7); echo $element-> plaintext . '<br>'; $element = $html->find("font[color=red]", 0); echo $element-> plaintext . '<br>'; $element = $html->find("font", 3); echo $element-> plaintext . '<br>'; # city state country $element = $html->find("font[size=2]", 3); echo $element-> plaintext . '<br>'; $element = $html->find("font[size=2]", 10); echo $element-> plaintext . '<br>'; $element = $html->find("font[size=2]", 11); echo $element-> plaintext . '<br>'; $element = $html->find("font[size=2]", 12); echo $element-> plaintext . '<br>'; $element = $html->find("font[size=-1]", 0); echo $element-> plaintext . '<br>'; $element = $html->find("font[size=-1]", 1); echo $element-> plaintext . '<br>'; $element = $html->find("font[size=-1]", 2); echo $element-> plaintext . '<br>'; $element = $html->find("font[size=-1]", 3); echo $element-> plaintext . '<br>'; $html->clear(); Quote Link to comment https://forums.phpfreaks.com/topic/273293-simple-html-dom-get-width-value/ Share on other sites More sharing options...
premiso Posted January 17, 2013 Share Posted January 17, 2013 (edited) According to the Sourceforge Code site: $element = $html->find("font[size=-1]", 3); echo "Width is: " . $element->width . '<br />'; Edited January 17, 2013 by premiso Quote Link to comment https://forums.phpfreaks.com/topic/273293-simple-html-dom-get-width-value/#findComment-1406540 Share on other sites More sharing options...
acctman Posted January 18, 2013 Author Share Posted January 18, 2013 According to the Sourceforge Code site: $element = $html->find("font[size=-1]", 3); echo "Width is: " . $element->width . '<br />'; I'm trying to check if there is and image after the <td> tag, and if there is grab the width value. the method i'm using below is not working $element = $html->find("td", 23); if ($element->innertext != null) { $element = $html->find("td img[src=http://pictures.domain.com/images/7.gif]"); echo $element->width . '<br />'; } else { echo "empty"; } Quote Link to comment https://forums.phpfreaks.com/topic/273293-simple-html-dom-get-width-value/#findComment-1406624 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.