BeautifulSoup error

W

William Xu

Hi, all,

This piece of code used to work well. i guess the error occurs after
some upgrade.
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/usr/lib/python2.3/sgmllib.py", line 94, in feed
self.rawdata = self.rawdata + data
UnicodeDecodeError: 'ascii' codec can't decode byte 0xb8 in position 565: ordinal not in range(128)
Any ideas to solve this?

version info:

Python 2.3.5 (#2, Mar 7 2006, 12:43:17)
[GCC 4.0.3 20060212 (prerelease) (Debian 4.0.2-9)] on linux2

python-beautifulsoup: 3.0.1-1
 
S

Serge Orlov

William said:
Hi, all,

This piece of code used to work well. i guess the error occurs after
some upgrade.

Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/usr/lib/python2.3/sgmllib.py", line 94, in feed
self.rawdata = self.rawdata + data
UnicodeDecodeError: 'ascii' codec can't decode byte 0xb8 in position 565: ordinal not in range(128)

Any ideas to solve this?

According to the documentation
<http://www.crummy.com/software/BeautifulSoup/documentation.html>
chapter "Beautiful Soup Gives You Unicode, Dammit" Beautiful Soup fully
supports unicode so it's probably a bug.
version info:

Python 2.3.5 (#2, Mar 7 2006, 12:43:17)
[GCC 4.0.3 20060212 (prerelease) (Debian 4.0.2-9)] on linux2

python-beautifulsoup: 3.0.1-1

Upgrading python-beautifulsoup is a good idea, since there were two bug
fix releases after 3.0.1
 
W

William Xu

[...]
Upgrading python-beautifulsoup is a good idea, since there were two bug
fix releases after 3.0.1

I just downloaded latest version 3.0.3 from its homepage, seems it still
has the same problem.

--
William

PL/I -- "the fatal disease" -- belongs more to the problem set than to the
solution set.
-- Edsger W. Dijkstra, SIGPLAN Notices, Volume 17, Number 5
 
S

Serge Orlov

William said:
Hi, all,

This piece of code used to work well. i guess the error occurs after
some upgrade.

Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/usr/lib/python2.3/sgmllib.py", line 94, in feed

Look at the traceback: you're not calling BeautifulSoup module! In
fact, there is no feed method in the current BeautifulSoup
documentation. Maybe it used to work well, but now it's definitely
going to fail. As I understand documentation you need to write

soup = BeautifulSoup(port)
 
W

William

[...]
Look at the traceback: you're not calling BeautifulSoup module! In
fact, there is no feed method in the current BeautifulSoup
documentation. Maybe it used to work well, but now it's definitely
going to fail. As I understand documentation you need to write

soup = BeautifulSoup(port)

Ah, yes ! Things change ! :)

BeautifulSoup feed() method used to exist before 3.0.0, and was left
over to SGMLParser later. As explained in the changlog,

http://www.crummy.com/software/BeautifulSoup/CHANGELOG.html

Release 3.0.0 (2006/05/28), "Who would not give all else for two p"

Beautiful Soup no longer implements a feed method. You need to pass a
string or a filehandle into the soup constructor, not with feed after
the soup has been created. There is still a feed method, but it's the
feed method implemented by SGMLParser and calling it will bypass
Beautiful Soup and cause problems.

Thanks for all the help !
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top