import requests, uuid
GATE = "gate.aeonproxy.com:7000"
# Country key only. Lookups print districts, so roll them up to the census islands.
# A Grand Bahama address can read town "Lucaya", region "Freeport".
ISLAND = {"New Providence": "New Providence", "Freeport": "Grand Bahama",
"West Grand Bahama": "Grand Bahama", "East Grand Bahama": "Grand Bahama",
"Central Abaco": "Abaco", "North Abaco": "Abaco", "South Abaco": "Abaco",
"North Eleuthera": "Eleuthera", "Central Eleuthera": "Eleuthera", "South Eleuthera": "Eleuthera"}
NETWORK = {"AS15146": "Cable Bahamas", "AS8014": "BTC"}
def bahamian_exit(island=None, tries=12):
for _ in range(tries):
sid = uuid.uuid4().hex[:8]
proxy = f"http://ap_a1b2c3-cc-bs-sid-{sid}-time-1800:PASS@{GATE}"
try:
geo = requests.get("https://ipinfo.io/json", proxies={"http": proxy, "https": proxy}, timeout=15).json()
except requests.RequestException:
continue # no reply: open a new session
if geo.get("country") != "BS":
continue # keep Bahamian exits only
geo["island"] = ISLAND.get(geo.get("region"), geo.get("region"))
geo["network"] = NETWORK.get(geo.get("org", "").split(" ")[0], geo.get("org"))
if island is None or geo["island"] == island:
return proxy, geo # this URL keeps its exit for 30 minutes
return None, None
proxy, geo = bahamian_exit("Grand Bahama")
if proxy:
print(geo["ip"], geo.get("city"), geo["island"], geo["network"])
Add Family Island districts to ISLAND as you meet them. -time- accepts 60 to 21600 seconds; without -sid- the exit changes per request. ISP and carrier keys stop at the US, the UK and Germany, so the ASN gives the network.