I can't fix the accents
Question:
I am having problems with a code created in python, and it is that when I generate some texts in json the accents are not appreciated
This is my code that I am using…
import requests
url = requests.get(f"https://images.habbo.com/habbo-web-news/es/production/front.json")
resumen = url.json()[0]['summary']
print(resumen)
I get these weird characters "& # x E D;"
Answers:
Hope this helps:
import html
import requests
url = requests.get(
f"https://images.habbo.com/habbo-web-news/es/production/front.json")
content = url.json()
summary = content[0]["summary"]
decoded = html.unescape(summary)
print (decoded)
Maybe it has to do with the encoding, please refer to the request documentation in the response content section. The "content" key on the json files have a strange format to be spanish, tho.
I am having problems with a code created in python, and it is that when I generate some texts in json the accents are not appreciated
This is my code that I am using…
import requests
url = requests.get(f"https://images.habbo.com/habbo-web-news/es/production/front.json")
resumen = url.json()[0]['summary']
print(resumen)
I get these weird characters "& # x E D;"
Hope this helps:
import html
import requests
url = requests.get(
f"https://images.habbo.com/habbo-web-news/es/production/front.json")
content = url.json()
summary = content[0]["summary"]
decoded = html.unescape(summary)
print (decoded)
Maybe it has to do with the encoding, please refer to the request documentation in the response content section. The "content" key on the json files have a strange format to be spanish, tho.