How can i extract only text in scrapy selector in python

前端 未结 5 825
[愿得一人]
[愿得一人] 2020-12-13 14:42

I have this code

   site = hxs.select(\"//h1[@class=\'state\']\")
   log.msg(str(site[0].extract()),level=log.ERROR)

The ouput is



        
5条回答
  •  不知归路
    2020-12-13 15:22

    I haven't got a scrapy instance running so I couldn't test this; but you could try to use text() within your search expression.

    For example:

    site = hxs.select("//h1[@class='state']/text()")
    

    (got it from the tutorial)

提交回复
热议问题