Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Get the html returned from the following url and scrape from it
- $html = file_get_contents('http://www.phoenixpark.ie/newsevents/2013/title,24194,en.html');
- $park_doc = new DOMDocument(); // Declare a new DOM object
- libxml_use_internal_errors(TRUE); // Disable libxml errors
- if(!empty($html)) // If any html is actually returned
- {
- $park_doc->loadHTML($html);
- libxml_clear_errors(); //remove html errors
- $xpath = new DOMXPath($park_doc); //DOMXPath allows queries with the DOM document.
- //perform queries to find information
- $event_title = $xpath->query('//h1[not(@class)]'); //gets the event title, ignores any other h1 headings on the page
- // Display contents of the scrape
- if($event_desc->length > 0)
- {
- foreach($event_title as $row)
- {
- echo $row->nodeValue . "<br/>";
- }
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement