在使用scrapy的解析过程中,我发现了这个输出
[u'TARTARINI AUTO SPA (CENTRALINO SELEZIONE PASSANTE)'],"[u'VCBONAZZI\xa043', u'40013', u'CASTEL MAGGIORE']",[u'0516322411'],[u'info@tartariniauto. it'],[u'CARS (LPG INSTALLERS)'],[u'track.aspx?id=0&url=http://www.tartariniauto.it']
如您所见,有一些额外的字符,例如
你'\xa043“'[]
这是我不想要的。我怎样才能删除这些?此外,此字符串中有 5 个项目。我希望字符串看起来像这样:
项目 1 , 项目 2 , 项目 3 , 项目 4 , 项目 5
这是我的 pipelines.py 代码
from scrapy.contrib.loader import ItemLoader
from scrapy.contrib.loader.processor import TakeFirst, MapCompose, Join
import re
import json
import csv
class InfobelPipeline(object):
def __init__(self):
self.file = csv.writer(open('items.csv','wb'))
def process_item(self, item, spider):
name = item['name']
address = item['address']
phone = item['phone']
email = item['email']
category = item['category']
website = item['website']
self.file.writerow((name,address,phone,email,category,website))
return item
谢谢