-1

Java を使用して Web ページを読み取り、フォーム要素にデータを書き込み、フォームを送信し、返された Web ページを読み取るにはどうすればよいですか?

具体的には、学籍番号を入力して提出し、結果ページを読んで、大学のWebサイトから学生の結果を表示したいです。

これをどのように実装できますか?

4

1 に答える 1

1

主に Web サイトをテストするためのライブラリであるHttpUnitを試すことができます。しかし、それはあなたのシナリオにも最適です。

例:

WebConversation wc = new WebConversation();
WebResponse top     = wc.getResponse( "http://www.meterware.com/Frames.html" ); // read a page with two frames
WebResponse summary = wc.getFrameContents( "summary" );                         // read the summary frame
WebLink     link    = summary.getLinkWith( "Cake Recipe" );                     // find the link (which targets "details" );
link.click();                                                                   // click on it
WebResponse response= wc.getFrameContents( "details" );                         // retrieve the details frame

編集

そして、HtmlUnitがあります。好みの問題だと思います。

于 2013-02-07T18:10:32.983 に答える