2016-11-04 15:33 阅读 71


I want to parsing data from homepage on this url. As you can see this url is HTML file and I read below:

// Create a DOM object from a HTML file
$html = file_get_html('test.htm');

so I just type a code below

include "simple_html_dom.php";
$html = file_get_html('');
echo $html->plaintext;

The error message is:

Error message Warning: file_get_contents(‌​m): failed to open stream: No such file or directory in C:\Bitnami\wampstack-5.6.27-0\apache2\htdocs\simple_html_dom‌​.php on line 76

what should I do?

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

1条回答 默认 最新

  • 已采纳
    doupuxuan5784 doupuxuan5784 2016-11-04 16:49

    You can get the HTML code using the Snoopy Class ( Next code displays the HTML code inside of a <textarea> tag, then it displays the page itself, copy-paste next code in a PHP file and open it in your browser:

    <!DOCTYPE html>
        <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=euc-kr">
        <META HTTP-EQUIV="Content-language" CONTENT="ko">
    require("Snoopy.class.php"); // ◄■■ GET SNOOPY FROM
    $snoopy = new Snoopy;
    $html = mb_convert_encoding( $snoopy->results, "UTF-8", "EUC-KR" ); // ◄■■ GET HTML CODE.
    echo "<textarea rows='25' cols='80'>$html</textarea>"; // ◄■■ DISPLAY THE HTML.
    echo $html; // ◄■■ DISPLAY THE WEBPAGE.

    The Snoopy Class is only one file, make sure the file is in the same directory your PHP file is.

    点赞 评论 复制链接分享