我正试图进行简单开采,但我仍然以无法预测的结果结束。
我有这一超文本。
<div class="thread" style="margin-bottom:25px;">
<div class="message">
<span class="profile">Suzy Creamcheese</span>
<span class="time">December 22, 2010 at 11:10 pm</span>
<div class="msgbody">
<div class="subject">New digs</div>
Hello thank you for trying our soap. <BR> Jim.
</div>
</div>
<div class="message reply">
<span class="profile">Lars Jörgenmeier</span>
<span class="time">December 22, 2010 at 11:45 pm</span>
<div class="msgbody">
I never sold you any soap.
</div>
</div>
</div>
而且,我试图从“人”中提取外文,但只有在“人”与东西相等时。 类似情况。
$contents = $html->find( .msgbody );
$elements = $html->find( .profile );
$length = sizeof($contents);
while($x != sizeof($elements)) {
$var = $elements[$x]->outertext;
//If profile = the right name
if ($var = $name) {
$text = $contents[$x]->outertext;
echo $text;
}
$x++;
}
I get text from the wrong profiles, not the ones with the associations I need. Is there a way to just pull the desired info with one line of code?
Like if span-profile = "correct name" then pull its div-msgbody