【问题标题】:explode grabbing page php curl to get row value爆炸抓取页面php curl获取行值
【发布时间】:2014-04-12 22:04:27
【问题描述】:

我已经从网页中抓取了一个页面并将其保存在我的变量 $result 中。现在我想分解它,因为我只想从包含我需要的信息的所有页面中获取 1 行。这是我抓取的 HTML 代码示例。

<pre>
.....
<tr class="altRowItem">

    <td class="center"></td>
    <td class="center"></td>
    <td class="center"></td>
    <td class="fareCol1"></td>
    <td class="fareCol2">
        <p>
            <input id="ControlGroupScheduleSelectView_AvailabilityInputScheduleSelectView_RadioButtonMkt1Fare4" type="radio" value="0~A~~A~RGFR~~1~X|QG~9743~ ~~CGK~04/18/2014 13:10~DPS~04/18/2014 15:55~" name="ControlGroupScheduleSelectView$AvailabilityInputScheduleSelectView$market1"></input>

            Rp.1,137,000
        </p>
    </td>
</tr>
.....
</pre>

我只需要从&lt;p&gt;&lt;/p&gt; 的字符串。这是我使用的代码。

$arrayResult[] = explode("<td class='fareCol2'>", $result);
echo $arrayResult[1];

$arrayResult[1] 中没有任何内容。谁能帮帮我?

【问题讨论】:

    标签: php html curl explode


    【解决方案1】:

    不需要[],也匹配引号格式

    $arrayResult = explode( '<td class="fareCol2">', $result);
    

    【讨论】:

    • 感谢您的回答。它工作得很好。我还是 php 新手。我不知道 $arrayResult 之前已经是数组了。
    猜你喜欢
    • 1970-01-01
    • 2012-08-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-05-30
    • 2010-12-20
    • 2014-11-01
    相关资源
    最近更新 更多