Re: Encoding question

2009-09-09 Thread Oleg Oltar
Well, I prefer to find alt tag inside my image and check that it's correct instead of, checking that whole response contains some text. btw, have a problem: b = BeautifulSoap(client.get("/")) b.find('img')["alt"] again gives me those strange symbols I am updating my django now. (was using 1.0)

Re: Encoding question

2009-09-09 Thread Karen Tracey
On Wed, Sep 9, 2009 at 5:06 AM, Oleg Oltar wrote: > Hi! > > One of my tests returned following text () > > The test: > from django.test.client import Client > c = Client() > resp = c.get("/") > resp.content > > In [25]: resp.content > Out[25]: '\r\n\r\n\r\n Strict//EN" [snip] > > Is there a way

Re: Encoding question

2009-09-09 Thread Oleg Oltar
It's more then great! Thanks! 2009/9/9 ray > > Hi Oleg > > You can use BeautifulSoup > > from BeautifulSoup import BeautifulSoup > >>> html = '\r\n\r\n\r\n Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";>\r\n\r\n xmlns="http://www.w3.org/1999/xhtml";>\r\n \r\n http-equiv="

Re: Encoding question

2009-09-09 Thread ray
Hi Oleg You can use BeautifulSoup from BeautifulSoup import BeautifulSoup >>> html = '\r\n\r\n\r\n>> Strict//EN" >>> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";>\r\n\r\n>> xmlns="http://www.w3.org/1999/xhtml";>\r\n \r\n>> http-equiv="content-type" content="text/html; charset=utf-8

Re: encoding question

2009-07-29 Thread Jarek Zgoda
Wiadomość napisana w dniu 2009-07-29, o godz. 10:04, przez alecs: > filename = smart_unicode(file.name, encoding='cp1251', > strings_only=False, errors='strict') > > destination = open('%s/%s' % (dir_path, filename), 'wb+') > > UnicodeEncodeError ('ascii', u'1.3.1.\u0421\u043b.\u041f > \u0435\u04

Re: encoding question

2009-06-25 Thread alexarsh
Hi, Thanks for the reply. I tried both but still got the same result. Maybe you have other ideas? Thanks, Alex A. On Jun 24, 7:51 pm, Gustavo Henrique wrote: > try: > > from unicodedata import normalize > mytext = '%u05D9%u05D2' > newtext = normalize('NFKD', mytext).encode('ASCII','ignore') >

Re: encoding question

2009-06-24 Thread Gustavo Henrique
try: from unicodedata import normalize mytext = '%u05D9%u05D2' newtext = normalize('NFKD', mytext).encode('ASCII','ignore') or: import sys reload(sys) sys.setdefaultencoding('latin-1') --~--~-~--~~~---~--~~ You received this message because you are subscribed to