Scrapy 符号替换
Scrapy symbol replace
我尝试从日期中删除 symsol ":" 但它不起作用:
oper_dates=response.css('.textonline__date::text').extract()
for item in oper_dates:
clean_oper_date = item.replace(':', '')
oper_dates 正确获取数据但替换后我得到空 csv。为什么?
您需要将替换后的结果放在某个地方,并在最后将其保存到 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
我尝试从日期中删除 symsol ":" 但它不起作用:
oper_dates=response.css('.textonline__date::text').extract()
for item in oper_dates:
clean_oper_date = item.replace(':', '')
oper_dates 正确获取数据但替换后我得到空 csv。为什么?
您需要将替换后的结果放在某个地方,并在最后将其保存到 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