File size: 452 Bytes
647d8a7
 
 
 
 
 
07cf852
 
 
 
647d8a7
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21

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')