import requests
# One line of your Spanish ISP order: dashboard -> My orders -> the order -> proxy list,
# with the protocol switch on HTTP
LINE = "IP:PORT:LOGIN:PASSWORD"
host, port, login, password = LINE.split(":")
proxy = f"http://{login}:{password}@{host}:{port}"
es = requests.Session()
es.proxies = {"http": proxy, "https": proxy}
# 1. through the proxy: where ipinfo.io places the address and which network announces it
seen = es.get("https://ipinfo.io/json", timeout=20).json()
if seen.get("country") != "ES":
raise SystemExit("stop, no account signs in: the country reads " + str(seen.get("country")))
print(seen["ip"], seen["country"], seen.get("city"), seen.get("timezone"), seen.get("org"))
# XX.XX.XX.XX ES, then the city, the time zone and "AS<number> <network name>"
# 2. the registry record, asked without the proxy (a plain requests.get): holder and country code
whois = requests.get("https://stat.ripe.net/data/whois/data.json",
params={"resource": seen["ip"]}, timeout=30).json()
for record in whois["data"]["records"]:
for field in record:
if field["key"].lower() in ("netname", "descr", "country"):
print(field["key"], field["value"])
# 3. only now the account, on this session and no other
page = es.get("https://www.example.com/mi-cuenta", timeout=30)
print(page.status_code)
Whether the network the script prints suits your platform is for you to judge.
# HTTP: the port printed on the IP's line
curl -sS -x http://LOGIN:PASSWORD@IP:PORT https://ipinfo.io/json
# "country": "ES", with "city", "org" and "timezone" for the address
# SOCKS5: the same IP on its SOCKS5 port; the host name is resolved at the proxy
curl -sS --socks5-hostname IP:SOCKS_PORT --proxy-user LOGIN:PASSWORD https://ipinfo.io/country
# ES
# the registry record of the address ipinfo.io printed, asked without the proxy
curl -sS "https://stat.ripe.net/data/whois/data.json?resource=XX.XX.XX.XX"