Java HTML / XML How to - Get form field by name and then get value








Question

We would like to know how to get form field by name and then get value.

Answer

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
/*from  w ww  . j  av  a2  s.  c  o  m*/
public class Main {

  public static void main(String[] args) throws Exception {
    String URL = "http://www.your server.com";
    Document doc = Jsoup.connect(URL).get();

    String cheapest = doc.select("input[name=p-min]").first().attr("value");
    System.out.println(cheapest);

  }
}