Okul web sitem için bir başvuru yapmaya çalışıyorum (reggienet.illinoisstate.edu), ancak girişe girme ve çerezleri saklıyorum. İnternette dolaştım ve bulabildiğim herşeyi denedim ama hiçbir şey işe yaramadı Tamamen kayboldum. İşte htmlUnit kullanarak okul web sitesine giriş yapın
Ben kodudur şu andapublic void login()
{
HtmlPage currentPage = null;
Scanner keyboard = new Scanner(System.in);
WebClient webClient = new WebClient();
try
{
webClient = reggieLogin(webClient, keyboard);
}
catch (Exception e)
{
e.printStackTrace();
}
try
{
currentPage = webClient.getPage(""https://reggienet.illinoisstate.edu/portal"");
}
catch (FailingHttpStatusCodeException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
catch (MalformedURLException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
String pageSource = currentPage.asXml();
System.out.print(pageSource);
}
private WebClient reggieLogin(WebClient webClient, Scanner keyboard) throws Exception
{
webClient.getOptions().setJavaScriptEnabled(false);
HtmlPage currentPage = webClient.getPage("https://account.illinoisstate.edu/centrallogin/"); //Load page at the STRING address.
HtmlInput username = currentPage.getElementByName("username"); //Find element called loginuser for username
System.out.print("ULID: ");
username.setValueAttribute(keyboard.nextLine()); //Set value for username
HtmlInput password = currentPage.getElementByName("password"); //Find element called loginpassword for password
System.out.print("Password: ");
password.setValueAttribute(keyboard.nextLine()); //Set value for password
HtmlButtonInput submitBtn = currentPage.getElementByName("submit"); //Find element called Submit to submit form.
currentPage = submitBtn.click(); //Click on the button.
return webClient;
}
herkes herhangi bir yardım sunabilir veya herkes bu kod nesi görebilir?
Belki JavaScriptEnabled öğesini true olarak ayarlamanız gerekir? Sadece modern web sitelerinin javascript'in etkin olması gerektiğinden, merak ediyorum. –
Tamam, bunu denedim ve ne yazık ki işe yaramadı, hala benim giriş yaptığımı anlamıyorum – Andrew