I’m using simple_html_dom.php to get all images from an url (like pinterest does)
if($_POST['submit']) {
$url = $_POST['form_url'];
$html = file_get_html($url);
$count = 0;
$goodfiles = array();
if($html && is_object($html) && isset($html->nodes)){
foreach($html->find('img') as $img){
$count++;
}
}else{
echo "failed";
}
echo $count;
}
}
for a lot of websites I receive a count of how many images are on the websites. But for example for the website pinterest.com I receive the following error:
Warning: file_get_contents(http://www.pinterest.com) [function.file-get-contents]: failed to open stream: Connection timed out in /home/vyrxkian/domains/bblablabla/include/simple_html_dom.php on line 70
failed 0
when I further specify the error I get this:
Warning: file_get_contents(http://www.pinterest.com) [function.file-get-contents]: failed to open stream: Connection timed out in /home/vyrxkian/domains/bblablabla/include/simple_html_dom.php on line 70
Fatal error: Call to a member function find() on a non-object in /home/vyrxkian/domains/bblablabla.php on line 30
how can I prefend this error and read for example pinterest.com
You may use CURL library: