Answer the question
In order to leave comments, you need to log in
Parsing json in python throws an error?
There is a site that gives us json, I want to access it, take a string with a certain key ("output:") and then work with it as a variable, in this output there are lines in Russian with a broken encoding (I would also restore it, I try to restore encodings on the site - it turns out :)) In short, there are a lot of problems, here is my code
url = 'сайт.ком.json'+'Привет, Мир'
response = requests.get(url)
print(response.json())
<script>
url = "сайт.ком.json";
input = encodeURIComponent ("Привет, мир");
function ProcessReply (data) {
if (data.error) console.log ('Error: ' + data.error);
else alert ('Reply: ' + data.output);
}
script_element = document.createElement('script'); //create new script element
script_element.src = url + "?input=" + input ;
document.getElementsByTagName ('head')[0].appendChild(script_element); //append to page, which executes it
</script>
Answer the question
In order to leave comments, you need to log in
Without json, it is not clear why the python swears and what is there with the encoding, get by key like this:print(response.json()['output:'])
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question