I have the following code
import requests
headers = {
'Host': 'extranet-lv.bwfbadminton.com',
'Content-Length': '0',
'Sec-Ch-Ua': '"Chromium";v="123", "Not:A-Brand";v="8"',
'Accept': 'application/json, text/plain, */*',
'Content-Type': 'application/json;charset=UTF-8',
'Sec-Ch-Ua-Mobile': '?0',
'Authorization': 'Bearer 2|NaXRu9JnMpSdb8l86BkJxj6gzKJofnhmExwr8EWkQtHoattDAGimsSYhpM22a61e1crjTjfIGTKfhzxA',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.6312.122 Safari/537.36',
'Sec-Ch-Ua-Platform': '"macOS"',
'Origin': 'https://match-centre.bwfbadminton.com',
'Sec-Fetch-Site': 'same-site',
'Sec-Fetch-Mode': 'cors',
'Sec-Fetch-Dest': 'empty',
'Referer': 'https://match-centre.bwfbadminton.com/',
'Accept-Encoding': 'gzip, deflate, br',
'Accept-Language': 'en-GB,en-US;q=0.9,en;q=0.8',
'Priority': 'u=1, i'
}
def get_tid() -> str:
URL = f'https://extranet-lv.bwfbadminton.com/api/vue-current-live'
r = requests.post(URL, headers=headers, json={'drawCount': '0'})
if r.status_code == 200:
encoded_r = r.text.encode('utf-8')
The output should look as follows:
{"results":[{"id":4746,"code":"DAC5B0C1-A817-4281-B3C6-F2F3DA65FD2B","name":"PERODUA Malaysia Masters 2024", ...}
If I’m not mistaken, the output of r.text
consists of unicode characters.
How do I transform this to the desired dictionary?