scrapy


span如果中间夹了其他的span。比如

<span> <span>aa </span> <span>bb </span>cc</span>

adpote [-1] to acquire “cc” if I want to get it instead of text() directly
amount4 = ingredient.xpath(‘span[@class=”recipe__list-qty”]/text()’)[-1].get()


Author: Moule Lin
Reprint policy: All articles in this blog are used except for special statements CC BY 4.0 reprint polocy. If reproduced, please indicate source Moule Lin !
  TOC