XPATH - 如何从平面结构中的html中获取数据?

时间:2013-12-03 09:57:31

标签: xpath

我再一次遭到XPATH的殴打。我只能抓住这个div而不是别的:

.//span[@class='noQuotes']

这给了我头衔。我已经尝试了所有其他可能性,但无法从此循环中获取单个项目。我尝试使用://div[@class='wrap']作为我的上下文,这似乎循环但不会抓住这些项目:

<div class="entry">
    <p class="partial_entry">
        <span class="ratingDate relativeDate"

我已尝试.//div[@class='entry']./div[@class='entry']/div[@class='entry']并尝试了p类但无法获取文本的一部分。任何人都可以帮我这个或告诉我哪里出错了?提前感谢任何指示。

<div class="wrap">
    <div class="quote">
        <a href="/example" onclick="ta.setEvtCookie('')" id="rn186515977">&#x201c;<span class='noQuotes'>Average</span>&#x201d;</a>
    </div>
    <div class="rating reviewItemInline">
        <span class="rate sprite-rating_s rating_s">
            <img class="sprite-rating_s_fill rating_s_fill s30" src="http://c1.tacdn.com/img2/x.gif" alt="3 of 5 stars" content="3.0">
        </span>
        <span class="ratingDate relativeDate" title='December 2, 2013'>Reviewed yesterday
            <span class="new">NEW</span>
        </span>
    </div>
    <div class="entry">
        <p class="partial_entry">
        Looks better in pictures, like the balcony and the bed but bit on the small side plus a 150-250 deposit is huge! 
        Close to canary wharf underground and has decent food places/shopping close by! Beautiful scenery and views from the balcony
        Price is very good, but have stayed in better for the price! asked for wifi code and was told...
            <span class="partnerRvw">
                <span class="example_1" onclick="example">
                More </span>
                <img class="textArrow_more sprite-text_arrow_dropdown_blu" src="http://dddd.gif" alt="" width="10" height="11">
            </span>
        </p>
    </div>
    <div class="wrap">
        <div id="helpfulq186515977_collapsed" class="helpful ">
            <span class="isHelpful"><strong>Was this review helpful?</strong></span>
            <span class="tgt_helpfulq186515977 rndBtn rndBtnGreen rndBtnSmall" onclick="ta.util.cookie.setPIDCookie(5034); ta.call('ta.servlet.Reviews.helpfulVoteHandlerOb', event, this, 'LeJIVqd4EVIpECri1qgqWQQoqnQQeVsSVuqHyUv3mmvqHMX3ookXqHxfqHqnEJtVEQQoqnQQwcJnVQQoqnQQfJCJEgQQoqnQQxdGJETqHRiCMiCQQoqnQQzsCycJCMxiGIac6XoXmqoTpcUv3oUoAkk0tEn1Uv3oUoAkk0zH1Uv3mmv0pSM1fqnm3AzsKKbXvvmmvokfoovUqnzsxMA3Xzszszsv0EJIVqiJcpV1U');; ta.trackEventOnPage('helpful_vote_button', 'Yes')">Yes</span>
        </div>
        <div class="wrap reportProblem">
            <span id="ReportIAP_186515977" class="problem collapsed taLnk" onclick="ta.trackEventOnPage('Reviews', 'report_problem', 'click'); ta.call('ta.overlays.Factory.iapFlyout', event, this, {voteContentType:'USERREVIEW', contentId: '186515977'})" onmouseover="ta.trackEventOnPage('Reviews', 'report_problem', 'hover_over_flag'); this.onmouseover=null">
                <span class="hidden ulBlueLinks">Problem with this review?</span>
                <img id='lazyload_483652333_2' height='14' alt='' width='13'/>
            </span>
    </div> </div>
</div>

0 个答案:

没有答案
相关问题