国际文本的scrapy问题 [英] Scrapy problem with international text

查看:38
本文介绍了国际文本的scrapy问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用scrapy从网页上抓取文本.在蜘蛛中,我有如下代码:

I did scraping text from webpage using scrapy. In spider, I have code like:

title = hxs.select("//h1/text()").extract() #1
final_text = title[0].encode('utf-8')   #2

这里的问题是第 1 行给出 [u'Puerto Ban\xfas']第 2 行给出了 Puerto Ban\xc3\xbas

Here problem is line #1 gives [u'Puerto Ban\xfas'] line #2 gives Puerto Ban\xc3\xbas

但原文是Puerto Banús.我怎样才能保存和显示这个原件?

But original text was Puerto Banús. How can I get this original saved and displayed?

推荐答案

>>> print u'Puerto Ban\xfas'
Puerto Banús
>>> print 'Puerto Ban\xc3\xbas'
Puerto Banús

我觉得这里没有问题.

这篇关于国际文本的scrapy问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆