Skip to content Skip to sidebar Skip to footer

'ascii' Codec Can't Decode Byte 0xcb While Doing Bs

I save the xml page locally from an API of Merriam-Webster, let me give you the url: http://www.dictionaryapi.com/api/v1/references/collegiate/xml/apple?key=bf534d02-bf4e-49bc-b43f

Solution 1:

You need to specify the encoding as utf-8 which is what the data is encoded as, the filename has nothing to do with what is inside so prefixing with u to make a unicode string is not going to help:

import io
with io.open('test.xml', encoding="utf-8") as page:
      bs = BeautifulSoup(page)

Post a Comment for "'ascii' Codec Can't Decode Byte 0xcb While Doing Bs"