Skip to content

Instantly share code, notes, and snippets.

@erasmas
Created May 7, 2012 13:44
Show Gist options
  • Save erasmas/2627847 to your computer and use it in GitHub Desktop.
Save erasmas/2627847 to your computer and use it in GitHub Desktop.
wifi authenticator
(ns epam-auth.core
(:import (com.gargoylesoftware.htmlunit WebClient))
(:gen-class :main true)))
(def client (doto (WebClient.)
(.setUseInsecureSSL true)
(.setJavaScriptEnabled true)))
(defn login-form []
(let [page (.getPage client "http://duckduckgo.com")
login-page (.click (.getElementByName page "login"))
forms (.getForms login-page)]
(first forms)))
(defn authenticate
[user pwd]
(let [login-form (login-form)
username-input (.getInputByName login-form "username")
password-input (.getInputByName login-form "password")
login-element (.getInputByName login-form "Login")]
(.setValueAttribute username-input user)
(.setValueAttribute password-input pwd)
(.click login-element)))
(defn -main
[& args]
(let [[user pwd _] args]
(authenticate user pwd)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment