title = each.xpath('div[@class="title"]/a/text()').extract()[0] #.decode('utf-8').encode('gb2312') rate = each.xpath('div[@class="rating"]/span[@class="rating_nums"]/text()').extract()[0] author = re.search('<div class="abstract">(.*?)<br', each.extract(), re.S).group(1) title = title.replace(' ', '').replace('\n', '') author = author.replace(' ', '').replace('\n', '') item['title'] =Py2utils.tran2GB18030(title) item['rate'] = rate item['author'] = Py2utils.tran2GB18030(author)
python生成中文编码只有GB18030是通用的,gbk不行
最新推荐文章于 2022-09-16 12:36:32 发布