0
我試圖從HtmlUnit訪問頁面https://www-banner.aub.edu.lb/pls/weba/bwckschd.p_disp_dyn_sched。當您從任何瀏覽器訪問該頁面時,該頁面不需要任何身份驗證,但是,當您通過代碼訪問該頁面時,該頁面會將我重定向到登錄頁面!任何解釋和解決方案?頁面驗證不需要通過瀏覽器,但需要從HtmlUnit
這是我的代碼:
final WebClient webClient = new WebClient();
// Get the first page
final HtmlPage page1 = webClient.getPage("http://www-banner.aub.edu.lb/pls/weba/bwckschd.p_disp_dyn_sched");
// Get the form that we are dealing with and within that form,
// find the submit button and the field that we want to change.
final HtmlForm form=page1.getFirstByXPath("//form[@action='/pls/weba/bwckgens.p_proc_term_date']");
final HtmlSubmitInput button = form.getInputByValue("Submit");
final HtmlHiddenInput field = form.getInputByName("p_calling_proc");
// Change the value of the text field
field.setValueAttribute("201350");
// Now submit the form by clicking the button and get back the second page.
final HtmlPage page2 = button.click();