PHP HTML DOM 解析

标签 php dom

<table width="100%" cellspacing="0" cellpadding="0" border="0" id="Table4">
  <tbody>
    <tr>
      <td valign="top" class="tx-strong-dgrey">
        <a class="anc-noul" href="http://www.example.com/catalog/proddetail.asp?logon=&amp;langid=EN&amp;sku_id=0665000FS10129471&amp;catid=25653">
          Apple 8GB 3rd Generation iPod Touch</a></td>
    </tr>
    <tr>
      <td valign="top" class="element-spacer"/>
    </tr>
    <tr>
      <td valign="top" class="tx-normal-grey">
        Product detail
        <a href="http://www.example.com/catalog/proddetail.asp?logon=&amp;langid=EN&amp;sku_id=0665000FS10129471&amp;catid=25653">
          More Info</a></td>
    </tr>
    <tr>
      <td valign="top" class="element-spacer"/>
    </tr>
    <tr>
      <td valign="top" class="tx-normal-red">
        <span class="tx-strong-dgrey">Price:</span>
        $189.99</td>
    </tr>
    <tr>
      <td valign="top">You save: $9.00 after instant savings</td>
    </tr>
    <tr>
      <td valign="top" class="element-spacer"/>
    </tr>
    <tr>
      <td valign="top" class="tx-normal-grey">
        <a href="http://www.example.com/catalog/subclass.asp?catid=25653&amp;logon=&amp;langid=EN">
          View similar products</a>  
        <a href="http://www.example.com/catalog/mfr.asp?man=Apple&amp;catid=19&amp;logon=&amp;langid=EN">
          View similar products with same brand</a>
      </td></tr>
    <tr>
      <td valign="top" class="element-spacer"/>
    </tr>
  </tbody>
</table>

我希望能够获得 189.99 美元。

echo $ret[0]->find('tr', 4)->plaintext;

输出:“价格:$189.99”

我只需要 189.99 美元,而不是“价格:”

最佳答案

$exp = explode(":", $ret[0]->find('tr', 4)->plaintext);
$price =$exp[1];

关于PHP HTML DOM 解析,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1784765/

相关文章:

php - mysql连接是如何工作的

javascript - 从另一个脚本源访问变量

html - polymer 纸-对话位置

javascript - 我可以向 DOM 对象添加任意属性吗?

php - 从MySQL数据库读取数据到android

php - 安全密码存储

php - jQuery PLUpload 如何重命名文件名?

PHP 数组 - `array_splice` 问题

javascript - 使用 Google 脚本从 html 中抓取表格

javascript - 如何使用 HTML/javascript 以预定义的顺序加载图像?