views:

89

answers:

0

i would like to know how to use the library in https://swingx-ws.dev.java.net/ to scrape a web page and submit a form.

the simple code writen below is simply not working and i don't know why. could someone help me?

thanks in advance.

    public static void main(String[] args) {
    try {
        Session s = new Session();
        Response r = s.get("http://www.webpage.com");

        Tidy tidy = new Tidy();
        tidy.setQuiet(true);
        tidy.setShowWarnings(false);
        Document tidyDOM = tidy.parseDOM(r.getBodyAsStream(), null);

        Form form = Forms.getFormByIndex(new SimpleDocument(tidyDOM), r.getBaseUrl(), 1);
        form.getInput("name").setValue("abcd");
        r = Forms.submit(form, s);

    } catch (Exception ex) {
        Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
    }
}