import re, requests, uuid
GATE = "gate.aeonproxy.com:7000"
# Country key only. GeoLite files every IPv4 block of these three networks under GI with no city,
# so test the country field and expect the city value to say little.
NET = {"AS202087": "GibFibre", "AS8301": "Gibtelecom", "AS34803": "U-Mee"}
LANGUAGE = {"en": "en-GB,en;q=0.9", "es": "es-ES,es;q=0.9"}
def gibraltar_exit(tries=8):
for _ in range(tries):
login = f"ap_a1b2c3-cc-gi-sid-{uuid.uuid4().hex[:8]}-time-1800"
proxy = f"http://{login}:PASS@{GATE}"
try:
info = requests.get("https://ipinfo.io/json", proxies={"http": proxy, "https": proxy}, timeout=15).json()
except requests.RequestException:
continue # timed out: try a new session
if info.get("country") == "GI":
info["network"] = NET.get(info.get("org", "").split(" ")[0], info.get("org"))
return proxy, info # good for the next 30 minutes
return None, None
def pounds(text):
# "£1,225,000", "£ 17,995.00" and "£699.00 GBP" all appear on Gibraltar sites
m = re.search(r"£\s*([\d,]+)", text)
return int(m.group(1).replace(",", "")) if m else None
proxy, info = gibraltar_exit()
if proxy:
print(info["ip"], info["network"], pounds("£ 17,995.00"))
for lang, value in LANGUAGE.items(): # the same page, asked for in each language
page = requests.get("https://gibraltar.com/property/", headers={"Accept-Language": value},
proxies={"http": proxy, "https": proxy}, timeout=20)
print(lang, page.status_code, pounds(page.text))
A site may ignore Accept-Language, so save the language that came back.