import network import ussl import socket import time def sock(host, port, ssl = False): s = socket.socket() ai = socket.getaddrinfo(host, port) addr = ai[0][-1] s.connect(addr) if ssl: return ussl.wrap_socket(s) else: return s def http_get(sock, host, path): sock.write(("GET " + path + " HTTP/1.1\r\nHost: " + host + "\r\nUser-Agent: curl/7.60.0\r\nAccept: */*\r\n\r\n").encode('utf-8')) return sock def connect_wlan(timeout = None): wlan = network.WLAN(network.STA_IF) wlan.active(True) if not wlan.isconnected(): start = time.ticks_ms() wlan.connect('@BayernWLAN') while wlan.status() != network.STAT_GOT_IP and (not timeout or time.ticks_diff(time.ticks_ms(), start) < timeout): time.sleep_ms(100) return wlan.status() def login_wlan(): s = sock("hotspot.vodafone.de", 443, True) http_get(s, "hotspot.vodafone.de", "/api/v4/login?loginProfile=6") return s connect_wlan() login_wlan().read(32)