In from subprocess import Popen PIPE In data Popen lynx -dump http 2ch

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
In [1]: from subprocess import Popen, PIPE
In [2]: data = Popen(["lynx", "-dump", "http://2ch.ru/b/"], stdout=PIPE).communicate()[0]
In [3]: data = data.decode('utf-8')
---------------------------------------------------------------------------
UnicodeDecodeError Traceback (most recent call last)
/home/xa4a/<ipython console> in <module>()
/usr/lib/python2.5/encodings/utf_8.py in decode(input, errors)
14
15 def decode(input, errors='strict'):
---> 16 return codecs.utf_8_decode(input, errors, True)
17
18 class IncrementalEncoder(codecs.IncrementalEncoder):
UnicodeDecodeError: 'utf8' codec can't decode bytes in position 1311-1312: invalid data