Spaces:
Running
Running
import requests | |
Regions = "IndiaPakistanBengal" | |
def check_region(ip): | |
session = requests.session() | |
# ret = requests.get(f"https://api.ip2location.io/?ip={ip}") | |
ret = requests.get(f"https://realip.cc/?ip={ip}") | |
# print(ret) | |
nat = ret.json()['country'].lower() | |
if nat in Regions.lower(): | |
print(nat, 'invalid') | |
return False | |
else: | |
print(nat, 'valid') | |
return True | |
check_region(ip='211.95.58.12') | |