Scrapy摸索爬去New York Time

放上一个典型错误

编码错误

 1 TypeError: can't concat bytes to str 

class TodaymoivePipeline(object):
    def process_item(self, item, spider):
        now=time.strftime('%Y-%m-%d',time.localtime())
        fileName='newYork'+now+'.txt'
        with open(fileName,'a') as fp:
            fp.write(item['moiveName'][0]+'\n\n') #fp.write(item['moiveName'][0].encode('utf-8')+'\n\n')
        return item

这段代码错误出现在爬取后没有写入到txt,注释内的是我原来采用的,所以是不需要编码直接写入?编码问题真是玄学...

posted @ 2017-09-25 08:02  vorphan  阅读(140)  评论(0编辑  收藏  举报