Search in sources :

Example 1 with Response

use of org.jsoup.Connection.Response in project ripme by RipMeApp.

the class HentaifoundryRipper method getFirstPage.

@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();
    // The only cookie that seems to matter in getting around the age wall is the phpsession cookie
    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();
}
Also used : Response(org.jsoup.Connection.Response)

Example 2 with Response

use of org.jsoup.Connection.Response in project ripme by RipMeApp.

the class HentaifoundryRipper method getURLsFromPage.

@Override
public List<String> getURLsFromPage(Document doc) {
    List<String> imageURLs = new ArrayList<>();
    Pattern imgRegex = Pattern.compile(".*/user/([a-zA-Z0-9\\-_]+)/(\\d+)/.*");
    for (Element thumb : doc.select("div.thumb_square > a.thumbLink")) {
        if (isStopped()) {
            break;
        }
        Matcher imgMatcher = imgRegex.matcher(thumb.attr("href"));
        if (!imgMatcher.matches()) {
            logger.info("Couldn't find user & image ID in " + thumb.attr("href"));
            continue;
        }
        Document imagePage;
        try {
            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());
            logger.info("grabbing " + "http://www.hentai-foundry.com" + thumb.attr("href"));
            imagePage = Http.url("http://www.hentai-foundry.com" + thumb.attr("href")).cookies(cookies).get();
        } catch (IOException e) {
            logger.debug(e.getMessage());
            logger.debug("Warning: imagePage is null!");
            imagePage = null;
        }
        // This is here for when the image is resized to a thumbnail because ripme doesn't report a screensize
        if (imagePage.select("div.boxbody > img.center").attr("src").contains("thumbs.")) {
            imageURLs.add("http:" + imagePage.select("div.boxbody > img.center").attr("onclick").replace("this.src=", "").replace("'", "").replace("; $(#resize_message).hide();", ""));
        } else {
            imageURLs.add("http:" + imagePage.select("div.boxbody > img.center").attr("src"));
        }
    }
    return imageURLs;
}
Also used : Response(org.jsoup.Connection.Response) Pattern(java.util.regex.Pattern) Matcher(java.util.regex.Matcher) Element(org.jsoup.nodes.Element) ArrayList(java.util.ArrayList) IOException(java.io.IOException) Document(org.jsoup.nodes.Document)

Example 3 with Response

use of org.jsoup.Connection.Response in project ripme by RipMeApp.

the class EightmusesRipper method getFirstPage.

@Override
public Document getFirstPage() throws IOException {
    if (albumDoc == null) {
        Response resp = Http.url(url).response();
        cookies.putAll(resp.cookies());
        albumDoc = resp.parse();
    }
    return albumDoc;
}
Also used : Response(org.jsoup.Connection.Response)

Example 4 with Response

use of org.jsoup.Connection.Response in project ripme by RipMeApp.

the class EroShareRipper method getFirstPage.

@Override
public Document getFirstPage() throws IOException {
    String urlToDownload = this.url.toExternalForm();
    Response resp = Http.url(urlToDownload.replace("eroshare.com", "eroshae.com")).ignoreContentType().response();
    return resp.parse();
}
Also used : Response(org.jsoup.Connection.Response)

Example 5 with Response

use of org.jsoup.Connection.Response in project ripme by RipMeApp.

the class EromeRipper method getURLs.

public static List<URL> getURLs(URL url) throws IOException {
    Response resp = Http.url(url).ignoreContentType().response();
    Document doc = resp.parse();
    List<URL> URLs = new ArrayList<>();
    // Pictures
    Elements imgs = doc.getElementsByTag("img");
    for (Element img : imgs) {
        if (img.hasClass("album-image")) {
            String imageURL = img.attr("src");
            imageURL = "https:" + imageURL;
            URLs.add(new URL(imageURL));
        }
    }
    // Videos
    Elements vids = doc.getElementsByTag("video");
    for (Element vid : vids) {
        if (vid.hasClass("album-video")) {
            Elements source = vid.getElementsByTag("source");
            String videoURL = source.first().attr("src");
            URLs.add(new URL(videoURL));
        }
    }
    return URLs;
}
Also used : Response(org.jsoup.Connection.Response) Element(org.jsoup.nodes.Element) ArrayList(java.util.ArrayList) Document(org.jsoup.nodes.Document) Elements(org.jsoup.select.Elements) URL(java.net.URL)

Aggregations

Response (org.jsoup.Connection.Response)28 Document (org.jsoup.nodes.Document)12 IOException (java.io.IOException)11 Element (org.jsoup.nodes.Element)10 HashMap (java.util.HashMap)8 URL (java.net.URL)4 Connection (org.jsoup.Connection)4 Elements (org.jsoup.select.Elements)4 ArrayList (java.util.ArrayList)3 BufferedWriter (java.io.BufferedWriter)1 File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 FileWriter (java.io.FileWriter)1 HttpURLConnection (java.net.HttpURLConnection)1 MalformedURLException (java.net.MalformedURLException)1 ParseException (java.text.ParseException)1 LocalDate (java.time.LocalDate)1 DateTimeParseException (java.time.format.DateTimeParseException)1 Map (java.util.Map)1 Matcher (java.util.regex.Matcher)1