Files
intaleq/scratch/test_api.py

18 lines
596 B
Python

import urllib.request
import json
def check_country(country):
url = "https://api.intaleq.xyz/intaleq_v3/ride/kazan/get.php"
data = json.dumps({"country": country}).encode('utf-8')
req = urllib.request.Request(url, data=data, headers={'Content-Type': 'application/json'})
try:
with urllib.request.urlopen(req) as response:
res = response.read().decode('utf-8')
print(f"Country: {country} -> {res}")
except Exception as e:
print(f"Country: {country} -> Error: {e}")
check_country("Jordan")
check_country("Syria")
check_country("Egypt")