Open andrewsu opened 6 years ago
You cannot parse a unicode string that contains an encoding declaration, see here. In Harvard's html the encoding is specified in the first line. You can just encode the text before passing it to extruct: data = extruct.extract(r.text.encode('utf8'), base_url=base_url)
Strings encoding are very confusing, this article helped me understanding the basis :)
Thank you @Kebniss, worked perfectly! Your help (and your addition to my must-read list) is much appreciated!
I think it's possible to make extruct work on such cases, and it should be a responsibility of the library.
Example document:
extruct.extract('<?xml version="1.0" encoding="utf-8"?><html><body>foo</body></html>')
Not about Unicode, but I got an issue when parsing from json-ld
structure has hex string in this url
The root cause is because of the description which is having hex string, and it is fixed by removing \x
according to this article
I think this case should be handled as well. Does anyone have any idea?
I'm trying to parse structured metadata from this url. I first executed this code on the example URL https://www.optimizesmart.com/how-to-use-open-graph-protocol/:
And works just fine. However, this block of code:
returns this error
Any idea what is going on here? Seems like an lxml.etree parsing error? Can I somehow modify
r.text
to fix this error? Any help is appreciated...