I want to grab the cover of the book on this HTML. The cover sometimes is at the first order, sometimes it is at the second order.
<div class="content">
<ul>
<li>
<b>Series</b>
Campell
</li>
<li>
<b>Hardcover:</b>
1465 pages
</li>
</ul>
</div>
I put the cover types in this list
cover = ['Hardcover', 'BoardBook', 'CardBook']
When I specifically write 'Hardcover'
in the xpath, it works.
response.xpath("//li/b[contains(text(),'Hardcover')]/text()").extract()
However, when I use the index of the list cover[0]
, it brings other things as well.
response.xpath('//li/b[contains(text(),cover[0])]/text()').extract()
I want to iterate the list values to check one of them between tags.