I have a HTML:
<div class="abc">
<div class="xyz">
<div class="needremove"></div>
<p>text</p>
<p>text</p>
<p>text</p>
<p>text</p>
</div>
</div>
I used: response.xpath('//div[contains(@class,"abc")]/div[contains(@class,"xyz")]').extract()
Result:
u'['<div class="xyz">
<div class="needremove"></div>
<p>text</p>
<p>text</p>
<p>text</p>
<p>text</p>
</div>']
I want remove <div class="needremove"></div>
. May you help me?
You can get all the child tags except the
div
withclass="needremove"
:Demo from the shell: