Reputation: 143
Hi I have a problem on getting HTML code without "\n" I tried normalize-space function but it seems that it just getting the first paragraph (Not the whole message)
Here's the code that I am using
response.xpath("normalize-space(//div[@class = 'messageContent'])").extract_first()
Without Normalize-space
<div> class="sample">\n
<span style="color:red;">Sample Message\n</span</div>
With Normalize-space
Sample Message
What I wanted is to also save the HTML code without "\n"
<div> class="sample">
<span style="color:red;">Sample Message</span</div>
Upvotes: 0
Views: 348
Reputation: 10210
If all you want is to remove the newline character from the output, just do it:
response.xpath("//div[@class = 'messageContent']").extract_first().replace('\n', '')
Upvotes: 1