Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
echo file_get_html('http://www.google.com)->plaintext;ウェブサイトから完全なコンテンツを取得するこのコードを見てください。それで、私の質問は、限られた単語を取得する方法です。180単語しか取得できないとします..何か考えはありますか?
echo file_get_html('http://www.google.com)->plaintext;
file_get_html は DOM オブジェクトを作成します。これにはページ全体の読み込み/解析が必要なため、必ずしも文字数で取得できるとは限りません。ただし、ファイル ハンドラーを開始して、特定のバイト数に fread することはできます。
$fh = fopen('google.com'); $data = fread($fh,$length); fclose($fh);
またはこれ:
$data = substr(file_get_contents('google.com'),$start,$end);