1
votes

Hi i have a issue in simple html dom code it show this error :-

file_get_contents(http://www.arakne-links.com) [function.file-get-contents]: failed to open stream: php_network_getaddresses: getaddrinfo failed: No such host is known. in D:\xampp\htdocs\scrap\simple_html_dom.php on line 75

because this url http://www.arakne-links.c is not working now i want

to know is there any way to skip the url which is not working..

here is the code which i am using

ini_set('display_errors', 'on'); 
include_once('../../simple_html_dom.php');

// create HTML DOM

$htmls =  file_get_html('http://info.vilesilencer.com/top');    
foreach($htmls->find('a[rel="nofollow"]') as $e):
$test = $e->href;
$url  = array( $test );
$html = array();
foreach( $url as $key=>$value ) { 

// get html plain-text for webpage & assign to html array.

$html = file_get_html( trim($value) ); 

// echo html plain text:
echo $html->find('title', 0)->innertext;

}     
endforeach; 

Please Help me to fix this issue.

Thankyou

1
where you are using the file_get_content function.user2334807
i thing i fix it and get in next url but now there is new error i replace this code $html = file_get_html( trim($value) ); // echo html plain text: echo $html->find('title', 0)->innertext; with $html = @file_get_html( trim($value) ); if($html){ echo $html->find('title', 0)->innertext; }else{ //Error echo 'not working'; } but now it showing some noticeCorlax
hello MIss poo i am using file_get_content here echo $html->find('title', 0)->innertext; its a simple_html_dom.php functionCorlax
what notice it is showing?user2334807

1 Answers

4
votes

How about checking the URL before parsing?

ini_set('display_errors', 'on'); 
include_once('simple_html_dom.php');

function urlOk($url) {
    $headers = @get_headers($url);
    if($headers[0] == 'HTTP/1.1 200 OK') return true;
    else return false;
}

// create HTML DOM

$htmls =  file_get_html('http://info.vilesilencer.com/top');    
foreach($htmls->find('a[rel="nofollow"]') as $e):
    $test = $e->href;
    $url  = array( $test );
    $html = array();
    foreach( $url as $key=>$value ) { 
       // get html plain-text for webpage & assign to html array.
       if (urlOk(trim($value))) {
           $html = file_get_html( trim($value) ); 
           echo $html->find('title', 0)->innertext;
           echo "<br />";
       } else {
         echo 'Error: URL '.$value.' doesn\'t exist.<br />';
       }
}     
endforeach; 
?>