Tried with the change.
{{{
...
...
-  myunistr = smart_str(fetch)
+ myunistr = smart_str(fetch.read())
...
...
}}}

Output:
{{{
Traceback (most recent call last):
  File "html2text.py", line 447, in <module>
    data = open(arg, 'r').read().decode(encoding)
  File "/usr/lib/python2.6/encodings/utf_8.py", line 16, in decode
    return codecs.utf_8_decode(input, errors, True)
UnicodeDecodeError: 'utf8' codec can't decode byte 0x88 in position 11366:
invalid start byte
}}}

Same error as before. !! ??






On Sun, Apr 17, 2011 at 9:08 PM, JAGANADH G <jagana...@gmail.com> wrote:

>
>
> On Sun, Apr 17, 2011 at 8:43 PM, Nikunj Badjatya <nikunjbadja...@gmail.com
> > wrote:
>
>> Thanks for the quick reply..
>> I hve never touched Django before.
>>
>> I tried as:
>>
>> {{{
>>
>> #!/bin/python
>>
>> import os
>> import urllib
>> + from django.utils.encoding import smart_str
>>
>> fetch = urllib.urlopen("some-web-link.htm")
>>
>> mainfile = open ('main.html', 'w' )
>>
>> + myunistr = smart_str(fetch)
>>
>> print myunistr
>>
>> mainfile.write(myunistr)
>>
>>
>> os.system('python2.6 html2text.py main.html > main.txt')
>>
>> }}}
>>
>> The execution went fine without any issues. But when I open the
>> "main.html". I was expecting it to havee full contents of the page . But it
>> has only ,
>> {{{
>> <addinfourl at 148983116 whose fp = <socket._fileobject object at
>> 0x8deabac>>
>> }}}
>>
>> Please let me know if I am missing something.
>>
>>
>
>
>
>  Change myunistr = smart_str(fetch) to
> myunistr = smart_str(fetch.read())
>
> --
> **********************************
> JAGANADH G
> http://jaganadhg.freeflux.net/blog
> *ILUGCBE*
> http://ilugcbe.techstud.org
>
>
_______________________________________________
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers

Reply via email to