Package org.jsoup.Connection

Examples of org.jsoup.Connection.Response


        Map<String,String> cookies  = null,
                           postData = new HashMap<String,String>();
        String gid = getGID(this.url),
               ref = "http://www.modelmayhem.com/" + gid;

        Response resp = null;
        String theurl = "http://www.modelmayhem.com/" + gid;
        logger.info("Loading " + theurl);
        resp = Jsoup.connect(theurl)
                    .timeout(5000)
                    .referrer("")
                    .userAgent(USER_AGENT)
                    .method(Method.GET)
                    .execute();
        cookies = resp.cookies();
       
        resp = Jsoup.connect("http://www.modelmayhem.com/includes/js/auth.php")
                .cookies(cookies)
                .ignoreContentType(true)
                .referrer(ref)
                .userAgent(USER_AGENT)
                .method(Method.GET)
                .execute();
        String authText = resp.parse().html();
        String mmservice = authText.substring(authText.indexOf("token = '") + 9);
        mmservice = mmservice.substring(0, mmservice.indexOf("'"));

        cookies.putAll(resp.cookies());

        cookies.put("worksafe", "0");
        theurl = "http://www.modelmayhem.com/services/photo_viewer/albums/" + gid;
        postData.put("MMSERVICE", mmservice);
        resp = Jsoup.connect(theurl)
                    .data(postData)
                    .cookies(cookies)
                    .referrer(ref)
                    .userAgent(USER_AGENT)
                    .method(Method.POST)
                    .execute();
        cookies.putAll(resp.cookies());

        theurl = "http://www.modelmayhem.com/services/photo_viewer/pictures/" + gid + "/0/0/1/0";
        this.sendUpdate(STATUS.LOADING_RESOURCE, theurl);
        logger.info("Loading " + theurl);
        resp = Jsoup.connect(theurl)
                    .data(postData)
                    .cookies(cookies)
                    .referrer(ref)
                    .userAgent(USER_AGENT)
                    .method(Method.POST)
                    .execute();

        Document doc = resp.parse();
        String jsonText = doc.body().html();
        jsonText = jsonText.replace("&quot;""\"");
        System.err.println(jsonText);
        JSONObject json = new JSONObject(jsonText);
        JSONArray pictures = json.getJSONArray("pictures");
View Full Code Here


    }

    @Override
    public Document getFirstPage() throws IOException {
        if (albumDoc == null) {
            Response resp = Http.url(url).response();
            cookies.putAll(resp.cookies());
            albumDoc = resp.parse();
        }
        return albumDoc;
    }
View Full Code Here

   
    private void login() throws IOException {
        String user = new String(Base64.decode("cmlwbWU="));
        String pass = new String(Base64.decode("cmlwbWVwYXNzd29yZA=="));

        Response loginPage = Http.url(urlBase + "/login/")
                                 .referrer(urlBase)
                                 .response();
        cookies = loginPage.cookies();

        Map<String,String> formData = new HashMap<String,String>();
        formData.put("action", "login");
        formData.put("retard_protection", "1");
        formData.put("name", user);
        formData.put("pass", pass);
        formData.put("login", "Login to FurAffinity");

        Response doLogin = Http.url(urlBase + "/login/?ref=" + url)
                               .referrer(urlBase + "/login/")
                               .cookies(cookies)
                               .data(formData)
                               .method(Method.POST)
                               .response();
        cookies.putAll(doLogin.cookies());
    }
View Full Code Here

    public void downloadURL(URL url, int index) {
        addURLToDownload(url, getPrefix(index));
    }
   
    private void login() throws IOException {
        Response resp = Http.url(this.url).response();
        cookies = resp.cookies();
        String ctoken = resp.parse().select("form > input[name=ctoken]").first().attr("value");

        Map<String,String> postdata = new HashMap<String,String>();
        postdata.put("user[login]", new String(Base64.decode("cmlwbWU=")));
        postdata.put("user[password]", new String(Base64.decode("cmlwcGVy")));
        postdata.put("rememberme", "1");
        postdata.put("ctoken", ctoken);

        resp = Http.url("http://en.2dgalleries.com/account/login")
                   .referrer("http://en.2dgalleries.com/")
                   .cookies(cookies)
                   .data(postdata)
                   .method(Method.POST)
                   .response();
        cookies = resp.cookies();
    }
View Full Code Here

        return new URL("http://gifyo.com/" + getGID(url) + "/");
    }
   
    @Override
    public Document getFirstPage() throws IOException {
        Response resp = Http.url(this.url)
                            .ignoreContentType()
                            .response();
        cookies = resp.cookies();

        Document doc = resp.parse();
        if (doc.html().contains("profile is private")) {
            sendUpdate(STATUS.RIP_ERRORED, "User has private profile");
            throw new IOException("User has private profile");
        }
        return doc;
View Full Code Here

        Map<String,String> postData = new HashMap<String,String>();
        postData.put("cmd", "refreshData");
        postData.put("view", "gif");
        postData.put("layout", "grid");
        postData.put("page", Integer.toString(page));
        Response resp = Http.url(this.url)
                            .ignoreContentType()
                            .data(postData)
                            .cookies(cookies)
                            .method(Method.POST)
                            .response();
        cookies.putAll(resp.cookies());
        Document nextDoc = resp.parse();
        if (nextDoc.select("div.gif img").size() == 0) {
            throw new IOException("No more images found");
        }
        sleep(2000);
        return nextDoc;
View Full Code Here

     * @return Cookies for logged-in session
     * @throws IOException
     */
    @SuppressWarnings("unused")
    private Map<String,String> signinToFlickr() throws IOException {
        Response resp = Jsoup.connect("http://www.flickr.com/signin/")
                            .userAgent(USER_AGENT)
                            .followRedirects(true)
                            .method(Method.GET)
                            .execute();
        Document doc = resp.parse();
        Map<String,String> postData = new HashMap<String,String>();
        for (Element input : doc.select("input[type=hidden]")) {
            postData.put(input.attr("name"),  input.attr("value"));
        }
        postData.put("passwd_raw""");
        postData.put(".save",   "");
        postData.put("login",   new String(Base64.decode("bGVmYWtlZGVmYWtl")));
        postData.put("passwd"new String(Base64.decode("MUZha2V5ZmFrZQ==")));
        String action = doc.select("form[method=post]").get(0).attr("action");
        resp = Jsoup.connect(action)
                    .cookies(resp.cookies())
                    .data(postData)
                    .method(Method.POST)
                    .execute();
        return resp.cookies();
    }
View Full Code Here

                        + " Got: " + url);
    }

    @Override
    public Document getFirstPage() throws IOException {
        Response resp = Http.url("http://www.hentai-foundry.com/").response();
        cookies = resp.cookies();
        resp = Http.url("http://www.hentai-foundry.com/?enterAgree=1&size=1500")
                   .referrer("http://www.hentai-foundry.com/")
                   .cookies(cookies)
                   .response();
        cookies.putAll(resp.cookies());
        sleep(500);
        resp = Http.url(url)
                   .referrer("http://www.hentai-foundry.com/")
                   .cookies(cookies)
                   .response();
        cookies.putAll(resp.cookies());
        return resp.parse();
    }
View Full Code Here

    }
   
    @Override
    public Document getFirstPage() throws IOException {
        if (albumDoc == null) {
            Response resp = Http.url(url).response();
            cookies.putAll(resp.cookies());
            albumDoc = resp.parse();
        }
        return albumDoc;
    }
View Full Code Here

        return intVersions;
    }

    private static void downloadJarAndLaunch(String updateJarURL)
            throws IOException {
        Response response;
        response = Jsoup.connect(updateJarURL)
                .ignoreContentType(true)
                .timeout(Utils.getConfigInteger("download.timeout", 60 * 1000))
                .maxBodySize(1024 * 1024 * 100)
                .execute();
        FileOutputStream out = new FileOutputStream(updateFileName);
        out.write(response.bodyAsBytes());
        out.close();
        logger.info("Download of new version complete; saved to " + updateFileName);

        // Setup updater script
        final String batchFile, script;
View Full Code Here

TOP

Related Classes of org.jsoup.Connection.Response

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.