Placeholder Placeholder - 5 months ago 71
PHP Question

PHP Failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in

I am currently using simple_html_dom.php and this is the first time I think I have stumbled into this problem and I am not sure the solution (been working on it for almost two hours now.)


Fatal error: Call to a member function find() on boolean in /m/viooz.ac.php on line 12


Above is the error that is displaying on our page when we try and scrape a
a
element of the requested site view the code below.

$page = (isset($_GET['p'])&&$_GET['p']!=0) ? (int) $_GET['p'] : '';
$html = file_get_html('http://viooz.ac/movies/page/1/');
foreach($html->find('a') as $element) {
print '<br><br>';
echo $url = ''.$element->href;
$html2 = file_get_html($url);
print '<br>';

$link = $html2->find('.cont_display a',0);
print $link = $link->href;
}


Now I know for sure that there's
<a href""></a>
tags on the site we're looking for how ever it keeps returning that error no matter what I change..

line 75 in simple_html_dom.php just says the following.

function file_get_html($url, $use_include_path = false, $context=null, $offset = -1, $maxLen=-1, $lowercase = true, $forceTagsClosed=true, $target_charset = DEFAULT_TARGET_CHARSET, $stripRN=true, $defaultBRText=DEFAULT_BR_TEXT, $defaultSpanText=DEFAULT_SPAN_TEXT)
{
// We DO force the tags to be terminated.
$dom = new simple_html_dom(null, $lowercase, $forceTagsClosed, $target_charset, $stripRN, $defaultBRText, $defaultSpanText);
// For sourceforge users: uncomment the next line and comment the retreive_url_contents line 2 lines down if it is not already done.
$contents = file_get_contents($url, $use_include_path, $context, $offset);
// Paperg - use our own mechanism for getting the contents as we want to control the timeout.
//$contents = retrieve_url_contents($url);
if (empty($contents) || strlen($contents) > MAX_FILE_SIZE)
{
return false;
}
// The second parameter can force the selectors to all be lowercase.
$dom->load($contents, $lowercase, $stripRN);
return $dom;
}



WARNING: Don't view the content destination unless you have an ad-block you will get loads of popups.


EDIT: Even after changing the url it returns the same issue


Fatal error: Call to a member function find() on boolean in /m/viooz.ac.php on line 18



  • I think I have figured something out though, when loading the page it creates a random div which triggers the popup and unless you delete that div or trigger it the other elements don't appear.. could this be what's causing our issue?


Answer

When I open your link (in Chrome incognito mode, with adblocker enabled) it really does give a 404. The page is not found, so your error is expected.

It appears you are missing a trailing slash. Add a final slash to your URL and it works.

So:

$html = file_get_html('http://viooz.ac/movies/page/'.$page.'/');

If you look at view-source:http://viooz.ac/movies/page/1/ in Chrome, you'll see the html code that I believe you expect to see.

I confirmed that file_get_contents('http://viooz.ac/movies/page/1/'); is successfully retrieving the HTML for me.

Comments