jeudi 2 février 2017

How to web scrape a site behind a log in? Using JSOUP

This is the link I am talking about

This page redirects to This

I want to get all the information of user after login . So far I have tried this , But got error :

    String url = "http://ift.tt/1BtdQeO";
    String userAgent = "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.130 Safari/537.36";

    Connection.Response response = Jsoup.connect(url).userAgent(userAgent)
            .method(Connection.Method.GET)
            .execute();

    System.out.print(response);

    response = Jsoup.connect(url)
            .cookies(response.cookies())
            .data("exam", "SSC/Dakhil")
            .data("year", "2008")
            .data("board", "Chittagong")
            .data("roll", "101945")
            .data("reg", "800179")
            .data("value_s", "15")
            .userAgent(userAgent)
            .method(Connection.Method.POST)
            .followRedirects(true)
            .execute();

    Document doc1 = Jsoup.connect("http://ift.tt/2l0CgdW")
            .cookies(response.cookies())
            .userAgent(userAgent)
            .get();

    System.out.println(doc1);

There is a mathematical sum which changes every time before submit . May be its creating a problem. Please tell me the solution .




Aucun commentaire:

Enregistrer un commentaire