BeautifulSoup error

Slawomir Nowaczyk slawomir.nowaczyk.847 at student.lu.se
Fri Jun 16 04:14:51 EDT 2006


On Fri, 16 Jun 2006 15:20:48 +1000
Ben Finney <bignose+hates-spam at benfinney.id.au> wrote:

#> > >>> soup = BeautifulSoup()
#> > >>> soup.feed(port)
#> > 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)
#> > >>>
#> 
#> Uses the default Python text encoding, 'ascii', when it needs to
#> decode the data in 'port' to Unicode. Some of the data in that
#> object makes no sense in the 'ascii' encoding, so it barfs.

In other words, this works for me:

>>> soup.feed( unicode(port,"iso-8859-1") )

-- 
 Best wishes,
   Slawomir Nowaczyk
     ( Slawomir.Nowaczyk at cs.lth.se )

^[:wq! Crap! Thought I was in vi.




More information about the Python-list mailing list