scrapy pass string as html 1

scrapy pass string as html

from scrapy.selector import Selector
body = 'good'
Selector(text=body).xpath('//span/text()').get()

Here is what the above code is Doing:
1. We create a Selector object by passing the HTML body to the constructor.
2. We use the xpath() method to extract the text inside the span tag.
3. We use the get() method to return the text as a string.

Similar Posts