While including the simple HTML DOM library, I get the warnings:
Warning: file_get_contents() [function.file-get-contents]: php_network_getaddresses: getaddrinfo failed: No such host is known. in C:\xampp\htdocs\simple_html_dom.php on line 70
Warning: file_get_contents(http://www.google.com/) [function.file-get-contents]: failed to open stream: php_network_getaddresses: getaddrinfo failed: No such host is known. in C:\xampp\htdocs\simple_html_dom.php on line 70
The line 70 in simple_html_dom.php file(downloaded from http://sourceforge.net/projects/simplehtmldom/files/latest/download) is
$contents = file_get_contents($url, $use_include_path, $context, $offset);
Also 1 error:
Fatal error: Call to a member function find() on a non-object in C:\xampp\htdocs\domdoc2.php on line 15
where line 15 of the code(below) is
foreach($html->find('img') as $element)
The web page i was referring in my code below is google.com Code follows:
<?php
include('simple_html_dom.php');
$html = new simple_html_dom();
$html = file_get_html('http://www.google.com/');
// Find all images
foreach($html->find('img') as $element)
echo $element->src . '<br>';
// Find all links
foreach($html->find('a') as $element)
echo $element->href . '<br>';
?>
What am I doing wrong??