'Server response problem with character encoding format in Spanish

I'm tryng to retrieve information from the following url:

https://fenixservices.fao.org/faostat/api/v1/es/data/PP?area=2%2C3%2C79%2C7%2C8%2C151%2C194%2C4%2C9%2C1%2C10%2C11%2C52%2C12%2C13%2C16%2C14%2C57%2C23%2C53%2C18%2C19%2C80%2C20%2C21%2C26%2C27%2C233%2C29%2C255%2C15%2C35%2C115%2C32%2C33%2C39%2C51%2C167%2C40%2C351%2C41%2C96%2C50%2C44%2C45%2C46%2C48%2C98%2C49%2C107%2C54%2C55%2C58%2C59%2C60%2C178%2C199%2C198%2C203%2C231%2C63%2C209%2C238%2C62%2C185%2C66%2C171%2C67%2C68%2C74%2C75%2C73%2C81%2C86%2C84%2C87%2C89%2C69%2C90%2C61%2C175%2C91%2C93%2C95%2C97%2C100%2C101%2C103%2C104%2C102%2C99%2C47%2C25%2C105%2C106%2C109%2C110%2C112%2C108%2C114%2C113%2C118%2C122%2C119%2C123%2C124%2C126%2C256%2C121%2C154%2C129%2C131%2C130%2C132%2C134%2C133%2C143%2C135%2C137%2C136%2C141%2C144%2C28%2C138%2C147%2C149%2C157%2C159%2C162%2C153%2C156%2C158%2C221%2C165%2C299%2C166%2C168%2C169%2C150%2C170%2C70%2C173%2C174%2C177%2C179%2C229%2C37%2C120%2C250%2C56%2C116%2C215%2C117%2C146%2C212%2C182%2C183%2C184%2C188%2C244%2C191%2C189%2C193%2C195%2C272%2C186%2C196%2C197%2C200%2C201%2C38%2C202%2C276%2C206%2C277%2C210%2C211%2C207%2C216%2C208%2C176%2C217%2C219%2C220%2C213%2C223%2C222%2C228%2C230%2C226%2C234%2C235%2C155%2C236%2C237%2C249%2C248%2C251%2C181&area_cs=FAO&element=5532&item=399%2C689%2C401%2C567&year=2017%2C2018%2C2019%2C2020&month=7004%2C7008%2C7012%2C7001%2C7002%2C7007%2C7006%2C7003%2C7005%2C7011%2C7010%2C7009%2C7021&show_codes=false&show_unit=true&show_flags=true&show_notes=true&null_values=false&output_type=objects

The server response replaces the letters with accent marks with question marks, here is the first line:

{"metadata": {"processing_time": 428,"datasource": "PRODUCTION","dsd": [{"label": "?mbito","type": "label","key": "?mbito","data_type": "string"},{"label": "?rea","type":

Is it possible to recover the character with the accent mark ?

import requests

url = "https://fenixservices.fao.org/faostat/api/v1/es/data/PP?area=2%2C3%2C79%2C7%2C8%2C151%2C194%2C4%2C9%2C1%2C10%2C11%2C52%2C12%2C13%2C16%2C14%2C57%2C23%2C53%2C18%2C19%2C80%2C20%2C21%2C26%2C27%2C233%2C29%2C255%2C15%2C35%2C115%2C32%2C33%2C39%2C51%2C167%2C40%2C351%2C41%2C96%2C50%2C44%2C45%2C46%2C48%2C98%2C49%2C107%2C54%2C55%2C58%2C59%2C60%2C178%2C199%2C198%2C203%2C231%2C63%2C209%2C238%2C62%2C185%2C66%2C171%2C67%2C68%2C74%2C75%2C73%2C81%2C86%2C84%2C87%2C89%2C69%2C90%2C61%2C175%2C91%2C93%2C95%2C97%2C100%2C101%2C103%2C104%2C102%2C99%2C47%2C25%2C105%2C106%2C109%2C110%2C112%2C108%2C114%2C113%2C118%2C122%2C119%2C123%2C124%2C126%2C256%2C121%2C154%2C129%2C131%2C130%2C132%2C134%2C133%2C143%2C135%2C137%2C136%2C141%2C144%2C28%2C138%2C147%2C149%2C157%2C159%2C162%2C153%2C156%2C158%2C221%2C165%2C299%2C166%2C168%2C169%2C150%2C170%2C70%2C173%2C174%2C177%2C179%2C229%2C37%2C120%2C250%2C56%2C116%2C215%2C117%2C146%2C212%2C182%2C183%2C184%2C188%2C244%2C191%2C189%2C193%2C195%2C272%2C186%2C196%2C197%2C200%2C201%2C38%2C202%2C276%2C206%2C277%2C210%2C211%2C207%2C216%2C208%2C176%2C217%2C219%2C220%2C213%2C223%2C222%2C228%2C230%2C226%2C234%2C235%2C155%2C236%2C237%2C249%2C248%2C251%2C181&area_cs=FAO&element=5532&item=399%2C689%2C401%2C567&year=2017%2C2018%2C2019%2C2020&month=7004%2C7008%2C7012%2C7001%2C7002%2C7007%2C7006%2C7003%2C7005%2C7011%2C7010%2C7009%2C7021&show_codes=false&show_unit=true&show_flags=true&show_notes=true&null_values=false&page_number=1&output_type=objects"

payload={}
headers = {}
response = requests.request("GET", url, headers=headers, data=payload)

data = response.content #Bytes
data = data.decode('utf-8')

Response header



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source