Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // example of how to use advanced selector features
- include('../simplehtmldom/simple_html_dom.php');
- // -----------------------------------------------------------------------------
- $phancach = "----------------------------------------------------------------------------- <br/>";
- // Retrieve the DOM from a given URL
- $html = file_get_html('http://libamboo.so/forum/');
- // Find all "A" tags and print their HREFs
- foreach($html->find('a') as $e)
- echo $e->href . '<br>';
- echo $phancach;
- // Retrieve all images and print their SRCs
- foreach($html->find('img') as $e)
- echo $e->src . '<br>';
- echo $phancach;
- // Find all images, print their text with the "<>" included
- foreach($html->find('img') as $e)
- echo $e->outertext . '<br>';
- echo $phancach;
- // Find the DIV tag with an id of "myId"
- foreach($html->find('div#myId') as $e)
- echo $e->innertext . '<br>';
- echo $phancach;
- // Find all SPAN tags that have a class of "myClass"
- foreach($html->find('span.myClass') as $e)
- echo $e->outertext . '<br>';
- echo $phancach;
- // Find all TD tags with "align=center"
- foreach($html->find('td[align=center]') as $e)
- echo $e->innertext . '<br>';
- echo $phancach;
- // Extract all text from a given cell
- echo $html->find('td[align="center"]', 1)->plaintext.'<br><hr>';
- ?>
Advertisement
Add Comment
Please, Sign In to add comment