I get Internet access from my city's free wifi access point 125 meters away, across the street.
I wrote a short Java program to automatically accept the terms of service on the city's AP login page. The idea is
to run this from my Ubuntu pc at startup (i.e. after a power failure) and periodically from a crontab,
so that my internet connection stays up without intervention from me. The Ubuntu pc is connected
to the AP through an OpenWRT router that is configured as a client.
I don't have a Java Runtime Environment on my OpenWRT router, which is why I don't run it directly on
the OpenWRT router.
I suppose you could modify this to connect to Starbucks etc. or any other AP that requires acceptance of
its terms of service. You would have to modify the code for your particular case.
I want to tweak this so that it is configurable at runtime, handles exceptions gracefully and directs
messages to syslog on a logserver. The logserver happens to be the same machine that this code will be running from.
This executes directly the same javascript that fires when you click on the 'Accept' button to accept
terms of service of the City of Bellevue's BellevueConnect free wifi service.
The code relies on HTMLUnit, which has a few dependencies that you need to make available
in your build path when you compile this.
Here's the code:
package bc;
import com.gargoylesoftware.htmlunit.WebClient;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
public class BellevueConnect {
/**
* @param args
*/
public static void main(String[] args) throws Exception{
final WebClient webClient = new WebClient();
final HtmlPage page = (HtmlPage) webClient.getPage("https://1.1.1.1/fs/customwebauth/login.html");
//final ScriptResult page2 = page.executeJavaScript("submitAction()");
page.executeJavaScript("submitAction()");
}
}