Вопрос

I am trying to submit a form with jsoup and then get the html from the directed page:

import org.jsoup.Connection;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;

public class RF {    

  public static void main(String[] args) throws Exception {

       Connection.Response submitForm =    Jsoup.connect("http://rfinder.asalink.net/free/")
        .method(Connection.Method.POST)
        .execute();

       Document data = Jsoup.connect("http://rfinder.asalink.net/free/autoroute_rtx.php")
        .data("cookieexists", "false")
        .data("id1", "LMML")
        .data("id2", "LIRA")
        .data("submit", "Find Route")
        .cookies(submitForm.cookies())
        .post();
       System.out.println(data);

   }

}

I think the problem may be that the submit button does not have a name tag and I don't know what to include instead of the 'submit' part.

What can I do please?

Это было полезно?

Решение

using jsoup to submit is not that easy, basically the motive of jsoup is to parse the html document for you, for submission of forms, and all other things that involve postback or getting results dynamically, i suggest you should use the Selenium, here is the basic tutorial to get you started

https://code.google.com/p/selenium/wiki/GettingStarted

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top