山东大学计算机计算机学院限选课刷课软件代码

import java.util.List;

import com.gargoylesoftware.htmlunit.WebClient;
import com.gargoylesoftware.htmlunit.html.HtmlForm;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
import com.gargoylesoftware.htmlunit.html.HtmlPasswordInput;
import com.gargoylesoftware.htmlunit.html.HtmlSubmitInput;
import com.gargoylesoftware.htmlunit.html.HtmlTextInput;

public class Main {
public static void main(String args[]) {
new Main();
}
private WebClient webClient;
private boolean isSelected;
public Main() {
webClient = new WebClient();
isSelected = false;
try {
rightPanel();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}

public void rightPanel() throws Exception {
// **************log in***********************
// Get the first page
HtmlPage page1 = webClient
.getPage("http://jwxt.sdu.edu.cn:7777/zhxt_bks/xk_login.html");

// 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.getFormByName("");
List<HtmlForm> forms = page1.getForms();
HtmlForm form = null;
for (int i = 0; i < forms.size(); i++) {
form = forms.get(i);
// System.out.println(form);
}

HtmlSubmitInput button = form.getInputByName("");
System.out.println(button);
HtmlTextInput nameField = form.getInputByName("stuid");
System.out.println(nameField);
HtmlPasswordInput passField = form.getInputByName("pwd");
System.out.println(passField);

// Change the value of the text field
nameField.setValueAttribute("200805270076");
passField.setValueAttribute("*********s");

// Now submit the form by clicking the button and get back the second
// page.
HtmlPage page2 = button.click();
System.out.println(page2.asXml());
HtmlPage page3 = webClient
.getPage("http://jwxt.sdu.edu.cn:7777/pls/wwwbks/xk.CourseInput");
System.out.println(page3.asXml());

// *****************select begin*******************
System.out.println("*******************************");
forms = page3.getForms();
for (int i = 0; i < forms.size(); i++) {
form = forms.get(i);
System.out.println(form);
}
button = form.getInputByName("");
System.out.println(button);
HtmlTextInput numField = form.getInputByName("p_qxrxk");
System.out.println(numField);
HtmlTextInput noField = form.getInputByName("p_qxrxk_kxh");
System.out.println(noField);
// select embedded system teached by Jia Zhiping.
HtmlPage page4;
while (!isSelected) {
numField.setValueAttribute("13105000");
noField.setValueAttribute("100");
page4 = button.click();
System.out.println(page4.asXml());
Thread.sleep(1000);
}
webClient.closeAllWindows();
}

class refreshThread extends Thread {
public refreshThread(String num) {

}
}
}

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值