html中清空元素文本内容,如何从html内容中删除“&nbsp”?

我有一个html页面:

Esquare Victory Camp

site no 2429,general thimayya road, camp contonment,oppositekayani bakery, Pune - 020 2613 2975

Drama - Hindi

10:30am

&nbsp

3:45

&nbsp

6:00

&nbsp

8:30pm

Action/Adventure/Thriller - English - Trailer

1:00

&nbsp

10:45pm

在那里我们可以看到我们有&nbsp在许多地方。还有许多其他unicode字符。我想提取这一页的内容。

我要做的是:def removeNonAscii(s): return "".join(i for i in s if ord(i)<128)

myName = soup.findAll("div", {"class" : "theater"})

for x in myName:

xt = str(x)

print removeNonAscii(xt)

print "
"

结果是:Esquare Victory Camp

site no 2429,general thimayya road, camp contonment,oppositekayani bakery, Pune - 020 2613 2975

Hawaa Hawaai

Drama - Hindi

10:30am &nbsp3:45 &nbsp6:00 &nbsp8:30pm

The Amazing Spider Man 2

Action/Adventure/Thriller - English - Trailer

1:00 &nbsp10:45pm

除了&nbsp,一切看起来都很好。我试着更换,也寻找其他解决方案,但仍然没有解决方案。我认为没有;的&nbsp会造成问题。如何删除&nbsp?

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值