ALex ALex - 7 months ago 18
HTML Question

If title contains a word that I'm searching I want that scrapy to copy "spec"

<div class="holder-specificatii">

<div class="box-specificatie" id="specifications-93-">
<div class="ch_group"></div>

<p class="ch_title">IPhone:</p>
<p class="ch_spec">iPhone 6</p>
<p class="ch_title">Tip Telefon:</p>
<p class="ch_spec">Smartphone</p>
<p class="ch_title">Sloturi Sim:</p>
<p class="ch_spec">Single Sim</p>
<div class="clear"></div>
</div>
</div>

Answer

If you're looking for a ch_title p that contains (for example) "Tip" and you want to select the next following ch_spec p, use this XPath:

//p[@class='ch_title'][contains(.,'Tip')]/following-sibling::p[@class='ch_spec'][1]

to return:

<p class="ch_spec">Smartphone</p>