Answer the question
In order to leave comments, you need to log in
Error unpacking Brotli?
There is such a code
import requests
import gzip
import brotli
import json
def getFlightDetails(query):
encodings = {
"": lambda x: x,
"br": brotli.decompress,
"gzip": gzip.decompress
}
headers = {
"accept-encoding": "gzip, br",
"accept-language": "pt-BR,pt;q=0.9,en-US;q=0.8,en;q=0.7",
"cache-control": "max-age=0",
"origin": "https://www.flightradar24.com",
"referer": "https://www.flightradar24.com/",
"sec-fetch-dest": "empty",
"sec-fetch-mode": "cors",
"sec-fetch-site": "same-site",
"user-agent": "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36"
}
url = f'https://data-live.flightradar24.com/clickhandler/?flight={query}'
request = requests.get(url, headers = headers)
contentEnc = request.headers.get("Content-Encoding", "")
content = request.content
contentType = request.headers.get["Content-Type"]
content = encodings[contentEnc](content)
return json.loads(content)
print(getFlightDetails('U6263'))
brotli.error: BrotliDecompress failed
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question