Created
May 7, 2012 13:44
-
-
Save erasmas/2627847 to your computer and use it in GitHub Desktop.
wifi authenticator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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