how to select and extract texts between two elements?

前端 未结 2 1335
Happy的楠姐
Happy的楠姐 2021-01-22 06:36

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


      
2条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-22 07:11

    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()
      

提交回复
热议问题