'Scrapy symbol replace

I try to delete symsol ":" from dates and it doesn't work:

 oper_dates=response.css('.textonline__date::text').extract()

 for item in oper_dates:
   clean_oper_date = item.replace(':', '')

oper_dates get data correctly but after replace I get empty csv. Why?



Solution 1:[1]

You need to place replaced result somewhere and save it at the end into csv:

 oper_dates=response.css('.textonline__date::text').extract()
 clean_oper_dates = []
 for item in oper_dates:
   clean_oper_date = item.replace(':', '')
   clean_oper_dates.append(clean_oper_date)
 
 # save clean_oper_dates into CSV

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 gangabass