import requests, uuid
GATE = "gate.aeonproxy.com:7000"
# Country key only. Lookups show Yas under its registry name, Telecom Malagasy,
# and town spellings differ between lists, so translate both before you filter.
OPERATOR = {"AS37054": "Yas", "AS37037": "Orange", "AS37303": "Airtel", "AS328411": "Gulfsat"}
TOWN = {"Diego Suarez": "Antsiranana", "Fort Dauphin": "Taolagnaro",
"Tolanaro": "Taolagnaro", "Toliary": "Toliara"}
def malagasy_exit(want=None, tries=12):
for _ in range(tries):
sid = uuid.uuid4().hex[:8]
login = f"ap_a1b2c3-cc-mg-sid-{sid}-time-1800:PASS"
proxy = f"http://{login}@{GATE}"
try:
geo = requests.get("https://ipinfo.io/json", proxies={"http": proxy, "https": proxy}, timeout=20).json()
except requests.RequestException:
continue # no reply: open another session
if geo.get("country") != "MG":
continue # country first
operator = OPERATOR.get(geo.get("org", "").split(" ")[0])
if operator is None or (want and operator != want):
continue # another network: try again
geo["town"] = TOWN.get(geo.get("city"), geo.get("city"))
return proxy, operator, geo # this exit stays for 30 minutes
return None, None, None
proxy, operator, geo = malagasy_exit("Orange")
if proxy:
print(geo["ip"], operator, geo["town"], geo.get("region"))
Call malagasy_exit() to accept any of the four. Passing a name, as the last lines do, only retries until that operator turns up, so it can return nothing; a login cannot choose a network, because network keys are limited to US, UK and German logins. -time- runs from 60 to 21600 seconds, and without -sid- every request gets a new exit.