how to select and extract texts between two elements?

前端 未结 2 1921
伪装坚强ぢ
伪装坚强ぢ 2021-01-22 06:42

I am trying to scrape this website using scrapy. The page structure looks like this:


      
2条回答
  •  情话喂你
    2021-01-22 06:57

    You can try to use below XPath expressions to fetch

    • all text nodes for "Follows" block:

      //div[./preceding-sibling::h4[1]="Follows"]//text()
      
    • all text nodes for "Followed by" block:

      //div[./preceding-sibling::h4[1]="Followed by"]//text()
      
    • all text nodes for "Spin off" block:

      //div[./preceding-sibling::h4[1]="Spin-off"]//text()
      

提交回复
热议问题