2017-07-29 22 views
3

私のlocalhostでHTML DOM解析を学習しようとしています。しかし、私はうまくいきなりクラッシュします。単純なHTML DOM解析が動作しません

1)私は、新しいプロジェクト )私は私が私のHTMLプロジェクト

<!DOCTYPE html> 
<!-- 
To change this license header, choose License Headers in Project Properties. 
To change this template file, choose Tools | Templates 
and open the template in the editor. 
--> 
<html> 
    <head> 
     <meta charset="UTF-8"> 
     <title></title> 
    </head> 
    <body> 
     <?php 
     // put your code here 
     $html = file_get_html('http://www.google.com/'); 
     ?> 
    </body> 
</html> 

4)私が手の内側にこのコードを入れている)simplehtmldom.sourceforge.net

3からファイルをダウンロードしたをしました

致命的なエラー:未知のエラー:C:\ xampp \ htdocs \ PhpProject1 \ index.phpの未定義関数file_get_html()を呼び出します:15 Stac kトレース:#0 {main}はC:\ xampp \ htdocs \ PhpProject1 \ index.phpに15行目で投げた

私はここで何かを誤解していますか?

+0

DOMパーサーを使用する必要があります。詳細はこちら[https://sourceforge.net/projects/simplehtmldom/files/] –

+0

@AshiqurRahmanこれらのファイルをダウンロードしてプロジェクトフォルダに保存しました – ragulin

+0

HTMLパーツにDOMパーサーPHPライブラリファイルを含める必要があります。 –

答えて

0

私はPHP DOMパーサライブラリは、もはやそうPHPの最新バージョンにサポートしていないと思います、あなたはそれはあなたを助けることのためにカールを使用する必要があります。

<?php 
$curl = curl_init(); 
curl_setopt($curl, CURLOPT_URL, "http://www.google.co.in"); 
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); 
$result = curl_exec($curl); 
curl_close($curl); 
print $result; 
?> 

試してみてください!

0

file_get_htmlは、phpに属しません。

これを使用するには、PHP Simple HTML DOM Parserをダウンロードして含める必要があります。

その後、あなたはあなたがPHPを使用して、HTMLコード内のDOMパーサPHPライブラリファイルをインクルードする必要があり、この

include_once('simple_html_dom.php'); 
$html = file_get_html('http://www.google.co.in'); 
0

のようにそれを使用することができ、機能が含まれています。

<html> 
    <head>  
     <meta charset="UTF-8"> 
     <title></title> 
    </head> 
    <body> 
     <?php 
      include_once('domparser.php');// use your file location 
     // put your code here 
     $html = file_get_html('http://www.google.com/'); 
     ?> 
    </body> 
</html> 
関連する問題