Php 从html源代码中删除评论和详细信息

Php 从html源代码中删除评论和详细信息,php,regex,web-scraping,Php,Regex,Web Scraping,我在看一页评论。我试图从页面中删除评论(尽管该站点提供了相同的API) 我看到每个评论都嵌入了li标签中。在litag中还有许多其他标记 在内部,有一个类名为review wrapper的div,其中包含带有rate和review的review 是否可以编写考虑所有这些容器和擦除检查的脚本、图像(如果存在)、速率和日期?< /强> regex是这样做的正确方法还是DOM合适 下面是代码狙击手: <div class="review-wrapper">

我在看一页评论。我试图从页面中删除评论(尽管该站点提供了相同的API)

我看到每个评论都嵌入了
li
标签中。在
li
tag中还有许多其他标记

在内部,有一个类名为
review wrapper
的div,其中包含带有rate和review的review

<强>是否可以编写考虑所有这些容器和擦除检查的脚本、图像(如果存在)、速率和日期?< /强>

regex
是这样做的正确方法还是
DOM
合适

下面是代码狙击手:

    <div class="review-wrapper">
           <div class="review-content">
        <div class="biz-rating biz-rating-very-large clearfix">
    <div itemprop="reviewRating" itemscope itemtype="http://schema.org/Rating">

    <div class="rating-very-large">
    <i class="star-img stars_5" title="5.0 star rating">
        <img alt="5.0 star rating" class="offscreen" height="303" src="http://s3-media3.ak.yelpcdn.com/assets/2/www/img/c2252a4cd43e/ico/stars/v2/stars_map.png" width="84">
    </i>
        <meta itemprop="ratingValue" content="5.0">
</div>


    </div>
        <span class="rating-qualifier">
        <meta itemprop="datePublished" content="2013-10-28">
    10/28/2013
</span>

</div>


            <p class="review_comment ieSucks" itemprop="description" lang="en">The reason I started a yelp account, was to write a review for Franchinos. This is my favorite restaurant in the city of San Francisco, and especially, North Beach. <br><br>Where do I start... I take every friend, family member and acquaintance to Franchinos in every opportunity I can. I am a Italy-nut and have been over three times - the mood + atmosphere is almost identical. It is a 100% family-run restaurant and you can taste the expertise and &#39;home-cooking&#39;. <br><br>Each time, I get a large bottle of wine (One time - they ran out of the wine I had ordered - and instead gave me a larger, more expensive bottle - same price), a wonderful pasta dish (Alfredo, carbonara.. etc.) and a Caesar salad.<br><br>Need I say more? Buenisimo. I look forward to the next time.. and the times after that again and again. <br><br>è perfetto!</p> 

</div>
<div class="review-footer clearfix">
               <div class="rateReview ufc-feedback clearfix" data-review-id="SnZ4Q97nJdR7a-fot-Slcw">
                <p class="review-intro review-message">
    Was this review &hellip;?
</p>

10/28/2013

我创建yelp帐户的原因是为Franchinos写一篇评论。这是我最喜欢的餐馆在旧金山市,特别是北滩。br>
我从哪里开始。。。我会尽我所能,把每一位朋友、家人和熟人带到弗兰基诺斯。我是一个意大利疯子,已经去过三次了——心情+气氛几乎是一样的。这是一家100%家庭经营的餐厅,您可以品尝到专业知识和';家常菜

每次,我都会得到一大瓶葡萄酒(有一次,他们把我点的葡萄酒喝光了,取而代之的是一瓶更大、更贵的葡萄酒,价格相同),一道美味的意大利面(阿尔弗雷多、卡博纳拉……等等)和一份凯撒沙拉。

我还需要说更多吗?布埃尼西莫。我期待着下一次。。在那之后的一次又一次

佩尔菲托

这是一篇评论吗;?


如果可能,请始终使用
DOM
而不是
regex
,如果html稍有更改,regex将失败。我编写regex是为了从源代码中删除图像、链接等。对dom不太了解。DOM是否可以循环遍历所有此类div并从每次审阅中收集数据?@Tuga:我编写regex是为了从源代码中删除图像、链接等。对dom不太了解。DOM是否可以遍历所有此类div并从每次审阅中收集数据?是的,请检查以下答案: