1
私はGet DIV content from external Websiteからの解決が好きですが、私の場合のように特定の文字列を含むDIVクラスから値を見つける必要がありますbtx764839(たとえば)。 divクラスの名前は文字列だけではなく、たとえば<div class="dark btx764839">76</div>
です。特定の文字列でDIVの内容を取得する
btx764839を含むDIVを検索するスクリプトが必要です。その特定のものを参照してください。私はで多くの異なることを試してきましたが、成功しませんでした。スクリプトの下で私は他の投稿で見つけました(調整なし)。私はいくつかの助けに感謝します。どうもありがとうございました!
$url = 'url';
$content = file_get_contents($url);
$first_step = explode('<div class="dark btx764839">' , $content);
$second_step = explode("</div>" , $first_step[1]);
echo $second_step[0];
これは私の最新の試みです:提供される例から取ら
$url = 'url';
$content = file_get_contents($url);
foreach($content as $div) {
// Loop through the DIVs looking for one withan id of "content"
// Then echo out its contents (pardon the pun)
// get class attribute of a div, it's a string
$class = $div->getAttribute('class');
// find substring 'btx764839' in $class
if (strpos($class, 'btx764839') !== false) {
echo $div->nodeValue;
}
}
申し訳ありませんが、私はどのように地雷を使用してコードを組み合わせることは考えています。コードは '$ url = 'url';'という別のページの内容を参照しています。 – vloryan