0

私のコードはオンラインストアからのアイテムの価格の外部部分をもたらすのにうまく機能していますが、標準のhtml、css、文字がロードされています。「、」のない数字、または「123」のような数字になりたいです。 "。

これは外部モバイルストアサイトの一部です。

<div class="prod-box-separation" style="padding-left:15px;padding-right:15px;text-align:center;padding-top:7px;">
   <div style="color:#cc1515;">
      <div class="price-box">
         <span class="regular-price" id="product-price-47488">
            <span >
               <span class="price">2.443,<sup>00</sup> RON</span>                                                    
            </span>
         </span>
      </div>
   </div>
</div>
<div class="prod-box-separation" style="padding-left:10px;padding-right:10px;">
   <style>
      .delivery {
     display:block;
      }
  </style>
  <p class="availability in-stock">
     <div class="stock_info">Produs in  stoc</div>
     <div class="delivery"><div class="delivery_title">Livrare(in timpul orelor de   program):</div>
     <div class="delivery_item">Bucuresti - BANEASA : imediat</div>
     <div  class="delivery_item">Bucuresti - EROILOR : luni dupa ora 13.00.</div>
     <div  class="delivery_item">CURIER : Marti</div>
  </div>
  </p>

Garanţie:12ルニ

これが私の実際のコードです:

<?php
include_once('../simple_html_dom.php');
$dom = file_get_html("http://www.site.com/page.html");
// alternatively use str_get_html($html) if you have the html string already...
foreach ($dom->find('span[class=price]') as $node)
{
echo $node->innertext;
} 
?>   

そして私の結果はこれです:2.443,<sup>00</sup> RONしかし正しい結果は次のようになります:2.443または2443

4

1 に答える 1

2

あなたはこのようなことをすることができます:

<?php
include_once('../simple_html_dom.php');
$dom = file_get_html("http://www.site.com/page.html");
// alternatively use str_get_html($html) if you have the html string already...
foreach ($dom->find('span[class=price]') as $node)
{
$result = $node->innertext;
$price = explode(",<sup>", $result);
echo $price[0];
} 
?>   
于 2013-01-27T21:57:20.740 に答える