Re: BeautifulSoup error



On Fri, 16 Jun 2006 15:20:48 +1000
Ben Finney <bignose+hates-spam@xxxxxxxxxxxxxxx> 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@xxxxxxxxx )

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

.



Relevant Pages