-2
我想從Play商店whatsapp中獲取新文本。我正在嘗試下面的代碼,它運行良好。PHP file_get_contents按類名從多個div中獲取所有內容
<?php
$url = 'https://play.google.com/store/apps/details?id=com.whatsapp&hl=en';
$content = file_get_contents($url);
$first_step = explode('<div class="recent-change">' , $content);
$second_step = explode("</div>" , $first_step[1]);
echo $second_step[0];
?>
問題是,此代碼僅顯示來自first recent-change div類的文本。它有多個div,最近更改類名稱。如何從中獲取所有內容?
[DOM日DOM DOM DOM(http://php.net/manual/en/class.domdocument.php) – CD001
請仔細閱讀[什麼話題能我問](http://stackoverflow.com/help/on-topic) 和[如何問一個好問題](http://stackoverflow.com/help/how-to-ask) 和[the完美的問題](http://codeblog.jonskeet.uk/2010/08/29/writing-the-perfect-question/) 以及如何創建[最小,完整和可驗證示例](http:// stackoverflow。 com/help/mcve) 還有[參觀](http://stackoverflow.com/tour) – RiggsFolly
你有使用domdocument導航與xpath! – MikeSouto