-1

我正在使用 PHP 开发一个应用程序,该应用程序使用 CURL 从另一个网页中提取所有句子。虽然我能够提取所有数据,但我发现很难提取一个完整的句子。我已经提到了所有相关的问题,并以我想要的方式帮助我。请指教

我需要从中提取完整句子的 html 内容

<p><font size="1" color="#C0C0C0">© Copyright <br></font><a href="http://www.dddddd.com" target="_blank"><font size="1" color="#C0C0C0">apple orange Ltd</font></a><font size="1"color="#C0C0C0"><a href="http://sm2.dddd.com/stats.asp?site=sm2ph0t0" target="_top"><img src="http://sm2.dddd.com/meter.asp?site=sm2ph0t0" alt="Site Meter" border=0></a></font></p></td><td valign="top" width="24"></td><!--msnavigation--><td valign="top"><p align="center"><a href="http://www.orangeapple.com" target="_blank"><img border="0" src="asddaf.jpg" alt="Sponsored by Ace Murder Mystery" width="85" height="121"></a><font face="Times New Roman"><b><b><u>Posters</u></b><br><font size="3" color="#008080">To find a large selection of jay joes prints and posters including framing options, please type the word..<font color="#996633"> asdasd </font></a><font color="#996633">&nbsp;</font> in the box below:<br><b>

基本上,如果您注意到可能会出现很多不相关的句子。我想从上面提取一个在字符串中至少包含“6”个单词的句子,我应该得到“To find a large selection of jay joes prints and posters”作为输出。

谢谢,杰

4

1 回答 1

0

我使用以下方法解决了这个问题

$paras = $doc->getElementsByTagName('p'); 

    for ($l = 0; $l < $paras->length; $l++)
    {
        $para = $paras->item($l);
        $paraContent = $para->textContent;
        $urlDet['para'] .= trim_text($paraContent, 1000);
    }

感谢任何试图回答的人...

于 2012-04-14T16:37:21.280 回答