How to fix unikalnoy JSON in Python?

Simply put I need to get the information, unfortunately I don't know if I was even going in the right direction. So instead of something to ask questions how to recode this page if decode("utf-8) not working. I'd rather ask you directly, how to get data which you can parse from this page.
Interested in the solution in Python so that I could do it. Thanks in advance.

# -*- coding: utf-8 -*- ?
import requests
import json

def GetJSON(word):
 url = "https://ru.wiktionary.org//w/api.php?action=query&titles=%s&prop=revisions&rvprop=content&format=json"
 url = url%word
 answ = requests.get(url).text
 data = json.load(answ)
 return data
print(GetJSON("cat"))

PS the hyperlink does not work-for some reason, just copy it
https://ru.wiktionary.org/w/api.php?action=query&titles=%D0%BA%D0%BE%D1%82&prop=revisions&rvprop=content&format=json

Solved!
Solution:
# coding: utf-8
import requests
def WikiSearch(word):
 req = requests.get('https://ru.wiktionary.org/w/api.php?action=query&titles=%s&prop=revisions&rvprop=content&format=json' % word)
 req = req.json()["query"]["pages"]

 for key in req: 
 if key == "-1": return None #404 page not found
 req = str(req[key]["revisions"])
 a = req.find("syllables")+6
 req = req[a:a+req[a:].find("}")]
 req = req.replace("\u0301","'")
 req = req.replace("|","")
 return req
print(WikiSearch(input()))

The program displays the word with the accent.
July 8th 19 at 16:00
3 answers
July 8th 19 at 16:02
Solution
Unfortunately the example is with url, but there are the code to load JSON from file, UTF-8, and the contents of the file in Russian. Here:
def LoadJson(filname):
 if os.path.isfile(filname) is False:
 return None
 data_file = open(filname, "r")
 str = data_file.read()
data_file.close()
 data = json.loads(str)
 str = json.dumps(data, ensure_ascii=False, indent=4)
 return json.loads(str)


I think the last three lines is what you need to pay attention to. After this magic - it worked. Maybe you like something simpler, do not understand much.
I've seen this, but the problem is that I have a byte string of the form "\uxx\uxx" - summer_Runolfsson commented on July 8th 19 at 16:05
Have updated the description. The hyperlink does not work. Just copy. I think it will become clear what the problem is. https://ru.wiktionary.org/w/api.php?action=query&t... - summer_Runolfsson commented on July 8th 19 at 16:08
Again, the Hyper link here in General... the post was cemented in the form of code.
https://ru.wiktionary.org/w/api.php?action=query&titles=%D0%BA%D0%BE%D1%82&prop=revisions&rvprop=content&format=json
- summer_Runolfsson commented on July 8th 19 at 16:11
as I recall, this is the problem output the dictionary to the console. For example, if you try sasevich this case to a file - then everything will be in normal encoding. Or if you try to print to the console a specific json element, not the whole - you will be fine. pastebin.com/exRJLWiq - here the code and file stampit in the correct encoding, and title in the console on Russian displays. - nicklaus commented on July 8th 19 at 16:14
: managed to fix the first problem, she was just reading. Instead .content to write .text that would read a Unicode string and not a byte. Now once again, the problem he can't convert exotic characters) - summer_Runolfsson commented on July 8th 19 at 16:17
have you ever opened a code that I gave? All perfectly displayed. - nicklaus commented on July 8th 19 at 16:20
: opened, but unfortunately the opportunity to fix it. I'll test it tomorrow. Thank you. - summer_Runolfsson commented on July 8th 19 at 16:23
however
os.path.isfile(filname) is False
return None - marilyne_Roh commented on July 8th 19 at 16:26
this code is ripped from the left-wing project :-) was Just an example of the trouble with janam and encodings. The link in the comments - slightly adjusted example author, in which everything is correctly displayed. Need improvement, of course. - nicklaus commented on July 8th 19 at 16:29
: condolences - marilyne_Roh commented on July 8th 19 at 16:32
and can a little more developed comment? How would you have implemented? - nicklaus commented on July 8th 19 at 16:35
:

if not os.path.isfile(file_path): return - marilyne_Roh commented on July 8th 19 at 16:38
OK, I agree, thank you for your comment. - nicklaus commented on July 8th 19 at 16:41
: is almost always a bad idea
a return statement returns none by default - marilyne_Roh commented on July 8th 19 at 16:44
July 8th 19 at 16:04
Solution
from json import loads
import requests

w = 'cat'
d = requests.get('https://ru.wiktionary.org/w/api.php?action=query&titles=%s&prop=revisions&rvprop=content&format=json' % w)
print(loads(d.text))
Yep, also noticed. But the mistake was not in it) - summer_Runolfsson commented on July 8th 19 at 16:07
I have the same, only more lines)
under load in the json gives an error, because of the inability to convert the character \u04e7 - summer_Runolfsson commented on July 8th 19 at 16:10
you have not the same
Carefully - summer_Runolfsson commented on July 8th 19 at 16:13
you are on the account .text? I already managed to find one of those toaster. Now the problem is convert exotic characters - On two points. - nicklaus commented on July 8th 19 at 16:16
: example? - summer_Runolfsson commented on July 8th 19 at 16:19
: this symbol \u04e7 - nicklaus commented on July 8th 19 at 16:22
:

In [7]: loads('{"q":"\u04e7"}')
Out[7]: {'q': 'a'}
- summer_Runolfsson commented on July 8th 19 at 16:25
: Can you please explain? - marilyne_Roh commented on July 8th 19 at 16:28
what? - nicklaus commented on July 8th 19 at 16:31
: So... problem solved. Now lay out the solution. - marilyne_Roh commented on July 8th 19 at 16:34
July 8th 19 at 16:06

Find more questions by tags JSONPythonProgrammingUnicode