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)
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
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="
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
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
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')
>
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
7 matches
Mail list logo