1
私はこれを解析したいと思っていますHTML
です。私は<input>
タグで自分の値を提出し、それを提出して次のHTML
文書を取得したいと思います。Jsoup formElement.submit()。post()指定された値をサブミットしません
私は解析テンプレートは次のとおりです。
* <div class="collapse navbar-collapse" id="search-collapse">
*
* <form class="navbar-form navbar-right search" method="get" action="http://search.azlyrics.com/search.php" role="search">
* <div class="input-group">
* <input type="text" class="form-control" placeholder="" name="q" id="q">
* <span class="input-group-btn">
* <button class="btn btn-primary" type="submit"><span class="glyphicon glyphicon-search"></span> Search</button>
* </span>
* </div>
* </form>
*
* </div>
私のコードは、異なる文書ではなく、私は彼の値を入力したものに私を取ります。
MyCode:searchedResultDocumentで
// Get to <form class="navbar-form navbar-right search" method="get" action="http://search.azlyrics.com/search.php" role="search">
FormElement formElement = htmlPage.getHtmlDocument().select("form.navbar-form.navbar-right.search").forms().get(0);
// Set my searched lyrics in the <input type="text" class="form-control" placeholder="" name="q" id="q">
formElement.select("input[name=q]").val(searchedLyrics);
// Get the HTML document after my searched lyrics applied
HtmlPage searchResultDocument = new HtmlPage(formElement.submit().post());
System.out.println(searchResultDocument.getHtmlDocument().text());
iは以前と同じページを取得し、値の後に提出します。
私は間違っていますか?
ご意見はお寄せください。
がどのように私は 'GET'作るのですか要求?ありがとうございました。そして、私はそれを知っているメモについて:)。私はちょうど私の 'HTML'構文解析スキルを練習したいと思います。 – God
@God確かに、サンプルで更新。 – alecxe
愚かな質問を申し訳ありません。ありがとうございました。 – God