Ascii codec can't encode
Marc 'BlackJack' Rintsch
bj_666 at gmx.net
Thu Oct 30 07:02:01 EDT 2008
On Thu, 30 Oct 2008 03:01:07 -0700, luca72 wrote:
> the code is this
> # -*- coding: ISO-8859-1 -*-
> from BeautifulSoup import BeautifulSoup import urllib
> sito = urllib.urlopen('http://text.net/') esamino = BeautifulSoup(sito)
> luca = esamino.findAll('tr', align='center') lunghezza = len(luca)
> messaggio_per_scar = open('me', 'wb') file_ricerca = open('ri', 'wb')
> for dati in range(lunghezza):
> gino = luca[dati]
> test = gino.findAll(text=True)
> print test
> valori_a = gino.find("a")["onclick"].split("'") print valori_a
> nome_boot = valori_a[1]
> print nome_boot
> frase_scar = '/msg '+nome_boot+' xdcc send '+test[0]+'\n\r'
> messaggio_per_scar.write(frase_scar)
> nome = test[2]
> if nome ==' ':
> nome = test[4]
> frase_ric = nome+' '+test[1]+' '+test[0]+'\n\r'
> file_ricerca.write(frase_ric) #here i have the error
> messaggio_per_scar.close()
> file_ricerca.close()
And which of those line raised the exception? Full traceback please.
I guess it is one of the ``print``\s because `BeatifulSoup` returns
`unicode` objects which may lead to that exception when printed and the
output encoding can not be determined.
Ciao,
Marc 'BlackJack' Rintsch
More information about the Python-list
mailing list