2016-06-08 2 views
0

현재 simple_html_dom.php을 사용하고 있는데이 문제가 발생하여 처음으로 해결책을 찾지 못했습니다. (거의 2 시간 동안 작업 중입니다.)PHP 스트림을 열지 못했습니다 : HTTP 요청에 실패했습니다! HTTP/1.1 404를 찾을 수 없음

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

위의 코드는 요청 된 사이트의 a 요소에 아래 코드를 표시하려고 시도 할 때 페이지에 표시되는 오류입니다.

$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; 
} 

지금은 우리가 아무리 내가 변경할 것을 그 오류를 반환하지 않습니다 유지하는 방법을 지금 찾고있는 사이트 <a href""></a> 태그가 있다는 것을 확실히 알고 .. simple_html_dom.php에서

라인 (75)은 단지 말한다 다음과 같은.

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.

편집 : 페이지를로드 할 때이 같은 문제가 내가 그래도 뭔가를 알아 낸 생각

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

  • 에게 반환하더라도 URL을 변경 한 후, 그것은 임의의 사업부를 생성하는 팝업을 시작하고 해당 div를 삭제하거나 트리거하지 않으면 다른 요소가 나타나지 않습니다 ..이 문제가 우리 문제의 원인 일 수 있습니까?
+1

하지만 ... http://viooz.ac/movies/page/1은 실제로 404를 제공합니다. 실제로 발견되지 않습니다. 따라서 귀하의 오류가 예상됩니다. 그게 무슨 문제 야? – jszobody

+0

@jszobody 내가 확인할 수있는 URL http://viooz.ac/movies/page/1/을 수정하더라도이 오류는 'a'요소를 찾을 때 동일하게 유지됩니다. – Placeholder

+0

당신이 얻으려고하는 페이지가 404를 던지고 있습니다 - 서버가 페이지를 찾을 수 없습니다. 페이지를 탐색 할 때 페이지가 표시 되더라도 200 OK 메시지 대신 404 오류가 전송됩니다. – aynber

답변

1

을 얻을 것이다, 자신의 URL에 후행 슬래시가 필요합니다 페이지가 없으므로 오류가 예상됩니다.

뒤에 슬래시가 없습니다. URL에 마지막 슬래시를 추가하면 작동합니다.

그래서 : 당신은 크롬에서 view-source:http://viooz.ac/movies/page/1/ 보면

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

, 당신은 당신이 볼 것으로 예상 믿는 HTML 코드를 볼 수 있습니다.

나는 file_get_contents('http://viooz.ac/movies/page/1/');이 나를 위해 HTML을 성공적으로 검색하고 있음을 확인했습니다.

+0

이게 내 문제를 해결했습니다. 정말 고마워요. – Placeholder

0

당신은 정말 404을 주는가 그렇지 않으면 404 페이지 (adblocker이 활성화 된 시크릿 모드 크롬에서) 나는 당신의 링크를 열

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

익명 downvote에 대한 어떤 이유? –

관련 문제