我尝试获取位于位置后面的法国:
我写了这个XPath://div[@class="vevent"]/div/div/span[text()="Location: "]
。那就是我走的路,但是我要如何获得之后的法国。
<div class="vevent">
<div style="float:left; padding-right: 20px;"><img alt="I’M YOUR DJ New Year Edition / 5th Anniversary Celebration" src="https://res.cloudinary.com/latindancecalendar/image/fetch/w_350,h_350/https%3A%2F%2Fi1.wp.com%2Flatindancecalendar.com%2Fdancecal%2Fwp-content%2Fuploads%2F50015933_2182298412088647_1361353647551676416_o.jpg%3Fresize%3D350%252C350%26ssl%3D1" width="200" height="200" scale="0"></div>
<div style="float:left;"><span class="dtstart"><span class="value-title" title="2019-12-27"></span></span><span><b>Friday, 27 December 2019</b></span>
<div><span class="location">Château Lafitte Yvrac ( Bordeaux ) - SCEA Chateau LAFITTE 41 Chemin du Loup, 33370 Yvrac, Aquitaine, France</span></div>
<div>Hosted by <b><a href="https://latindancecalendar.com/im-your-dj-new-year-edition-bordeaux/">I’M YOUR DJ – New Year Edition – Bordeaux</a></b></div>
<div><span>Location: </span>France</div>
<div><span class="eventpostviews"><a href="https://maps.google.com/?q=Ch%C3%A2teau+Lafitte+Yvrac+%28+Bordeaux+%29+-+SCEA+Chateau+LAFITTE+41+Chemin+du+Loup%2C+33370+Yvrac%2C+Aquitaine%2C+France" class="map_link" target="_blank" rel="nofollow"><i class="fas fa-map-marker-alt" style="padding-right: 5px;"></i>Map</a> | 175 Views | <a style="color:#8F8F8F;" href="https://latindancecalendar.com/report-a-listing/?listing-url=https%3A%2F%2Flatindancecalendar.com%2Ffestivals%2Fim-your-dj-new-year-edition-5th-anniversary-celebration-2019%2F" rel="nofollow"><i class="fas fa-times" style="padding-right: 3px;font-size: 11px;"></i>Report Problem</a></span></div>
<div style="padding-top: 20px;">
<iframe src="//www.facebook.com/plugins/like.php?href=https%3A%2F%2Flatindancecalendar.com%2Ffestivals%2Fim-your-dj-new-year-edition-5th-anniversary-celebration-2019%2F&width&layout=button_count&action=like&size=large&show_faces=false&share=false&height=35&appId=532405580227185" scrolling="no" frameborder="0" style="border:none; overflow:hidden; height:35px;" allowtransparency="true"></iframe>
</div>
</div>
</div>
答案 0 :(得分:0)
这应该有效:
//div[@class="vevent"]/div/div[span = "Location: "]/text()
它选择包含字符串值div
的{{1}}的{{1}},然后直接在该span
内检索文本节点。
答案 1 :(得分:0)
最好在脚本中提供html。没有图片。 我想您可以使用: ''' 以下:: text() '''