I\'m building a data extract using scrapy and want to normalize a raw string pulled out of an HTML document. Here\'s an example string:
Sapphire RX460 OC
You can use a function like below with regular expression to scan for continuous spaces and replace them by 1 space
import re
def clean_data(data):
return re.sub(" {2,}", " ", data.strip())
product_title = clean(product.css('h3::text').extract_first())
And then improve clean function anyway you like it