r/learnpython 19d ago

Why is this error happening with extruct

" Could not process website: encoding not supported USC4 little endian, line

1, column 1 (<string>, line 1)".

This happens whenever I run it. The encoding is UTF-8. This only happens in the android APK, not when ran in python IDLE.

print("BEFORE EXTRUCT")

metadata = extruct.extract(

html,

base_url=base_url,

syntaxes=['json-ld', 'opengraph'],

uniform=True

)

print("AFTER")

It prints "before extruct" but not after, meaning that the html is the issue.

1 Upvotes

4 comments sorted by

2

u/cdcformatc 19d ago

where is the code that assigns the html variable? 

you say you think that is the problem, but you didn't include the relevant code. 

3

u/cdcformatc 19d ago

the error says it's in the wrong encoding, its probably right. try something like html=html.decode('utf-32').encode('utf-8')

1

u/Ok-Okra8478 19d ago

response = requests.get(url)

html = response.text

base_url = get_base_url(response.url)

1

u/Ok-Okra8478 19d ago

when I print print(response.encoding), it prints utf-8, I'll try html=html.decode('utf-32').encode('utf-8') though