import urllib.request, urllib.parse, http.cookiejar, re, sys, ssl, json

ctx = ssl.create_default_context(); ctx.check_hostname=False; ctx.verify_mode=ssl.CERT_NONE
cj = http.cookiejar.CookieJar()
opener = urllib.request.build_opener(urllib.request.HTTPCookieProcessor(cj), urllib.request.HTTPSHandler(context=ctx))

dom = "exnessvpn74efaadb"

# Step 1: hit login?generateRequest=github to see what it returns
try:
    r = opener.open("https://www.duckdns.org/login?generateRequest=github", timeout=20)
    html = r.read().decode('utf-8','ignore')
    print("LOGIN status", r.status, "len", len(html))
    # find forms and oauth urls
    for m in re.finditer(r'<form[^>]*action="([^"]+)"', html):
        print("FORM:", m.group(1))
    for m in re.finditer(r'(https?://[^\s"]*oauth[^\s"]*)', html):
        print("OAUTH URL:", m.group(1)[:120])
    for m in re.finditer(r'<input[^>]*name="([^"]+)"[^>]*(value="([^"]*)")?', html):
        print("INPUT:", m.group(1), "=", m.group(3) if m.group(3) else "")
except Exception as e:
    print("err", e)
