import requests, uuid
GATE = "gate.aeonproxy.com:7000"
# Country key only. GeoNames lists Slovenia's 212 municipalities as its first-level
# units (not the 12 statistical regions), so print the region field and read it as such.
NET = {"AS5603": "Telekom Slovenije", "AS3212": "Telemach",
"AS21283": "A1", "AS34779": "T-2", "AS9119": "Softnet"}
def slovenian_exit(network=None, tries=8):
for _ in range(tries):
sid = uuid.uuid4().hex[:8]
proxy = f"http://ap_a1b2c3-cc-si-sid-{sid}-time-21600:PASS@{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") != "SI":
continue # placed outside Slovenia: skip it
net = NET.get(geo.get("org", "").split(" ")[0], geo.get("org"))
if network is None or net == network:
return proxy, geo, net # held for up to 6 hours
return None, None, None
proxy, geo, net = slovenian_exit("Telemach")
if proxy:
print(geo["ip"], geo.get("city"), geo.get("region"), net)
"Telekom Slovenije", "A1" and "T-2" work the same way. -time- takes 60 to 21600 seconds; with no -sid-, every request rotates. Print the region field as well: GeoNames uses municipalities as Slovenia’s first-level units.