2

http://www.reuters.com/article/2012/04/01/net-us-foxconn-idUSBRE83004E20120401から記事を取得するためにBeautifulSoupを使用しています

url="http://www.reuters.com/article/2012/10/19/us-yahoo-korea-idUSBRE89I0EY20121019"
source = urllib2.urlopen(url)
soup = BeautifulSoup(source)

しかし、エラー UnicodeDecodeError: 'utf8' codec can't decode byte 0x80 in position 107: invalid start byte を受け取ります

私はsoup.encode(['windows-1252','ascii','iso-8859'])を使用しようとしましたが、そもそもスープを作成することさえできません。

共有するヒントはありますか?

役立つ場合は、エラーのトレースバック:

Traceback (most recent call last):
File "<pyshell#17>", line 1, in <module>
parseReuters()
File "C:\Users\name\Desktop\test.py", line 39, in parseReuters
soup = BeautifulSoup(source)
File "C:\Python27\lib\site-packages\bs4\__init__.py", line 172, in __init__
self._feed()
File "C:\Python27\lib\site-packages\bs4\__init__.py", line 185, in _feed
self.builder.feed(self.markup)
File "C:\Python27\lib\site-packages\bs4\builder\_lxml.py", line 195, in feed
self.parser.close()
File "parser.pxi", line 1209, in lxml.etree._FeedParser.close (src\lxml\lxml.etree.c:90597)
File "parsertarget.pxi", line 142, in lxml.etree._TargetParserContext._handleParseResult (src\lxml\lxml.etree.c:99984)
File "parsertarget.pxi", line 130, in lxml.etree._TargetParserContext._handleParseResult (src\lxml\lxml.etree.c:99807)
File "lxml.etree.pyx", line 294, in lxml.etree._ExceptionContext._raise_if_stored (src\lxml\lxml.etree.c:9383)
File "saxparser.pxi", line 259, in lxml.etree._handleSaxData (src\lxml\lxml.etree.c:95945)
UnicodeDecodeError: 'utf8' codec can't decode byte 0x80 in position 0: invalid start byte
4

0 に答える 0