【发布时间】:2011-03-10 11:59:05
【问题描述】:
我目前正在使用 BeautifulSoup 抓取一些网站,但是我遇到了一些特定字符的问题,UnicodeDammit 中的代码似乎(再次)表明这是一些微软发明的。
我正在使用最新版本的 BeautifulSoup(3.0.8.1),因为我仍在使用 python2.5
以下代码说明了我的问题:
from BeautifulSoup import BeautifulSoup
soup = BeautifulSoup('...Baby One More Time (Digital Deluxe Version…')
print soup
'...Baby One More Time (Digital Deluxe Version…'
如您所见,问题在于末尾的 '...'(&hellip) 字符(您的浏览器可能正确转义了该字符)。显然这不是我感兴趣的。
如果有这个字符的 unicode 表示或其他东西会很好。 即使只是简单地忽略它也会解决我的特殊问题。
BeautifulSoup 如何做到这一点?
【问题讨论】:
标签: python escaping beautifulsoup web-scraping