Package org.jsoup.nodes

Examples of org.jsoup.nodes.Document.body()


    public String forContent(String content, int maxLength) {
        Document document = Jsoup.parse(content);
        StringBuilder builder = new StringBuilder();
        int count = 0;
        for (Element element : document.body().children()) {
            builder.append(element.outerHtml());
            builder.append("\n");
            count += element.text().length();
            if (count >= maxLength)
                break;
View Full Code Here


    @Override
    public void rip() throws IOException {
        logger.info("    Retrieving " + this.url.toExternalForm());
        Document doc = Http.url(this.url).get();
        Pattern p = Pattern.compile("^.*var flashvars = (.*});.*$", Pattern.DOTALL);
        Matcher m = p.matcher(doc.body().html());
        if (m.matches()) {
            String title = null,
                   encryptedUrl = null;
            try {
                JSONObject json = new JSONObject(m.group(1));
View Full Code Here

                           .header("Authorization", "Basic " + authKey)
                           .header("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8")
                           .header("User-agent", "ripe and zipe")
                           .data("grant_type", "client_credentials")
                           .post();
        String body = doc.body().html().replaceAll(""", "\"");
        try {
            JSONObject json = new JSONObject(body);
            accessToken = json.getString("access_token");
            return;
        } catch (JSONException e) {
View Full Code Here

                            .ignoreContentType()
                            .header("Authorization", "Bearer " + accessToken)
                            .header("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8")
                            .header("User-agent", "ripe and zipe")
                            .get();
        String body = doc.body().html().replaceAll(""", "\"");
        try {
            JSONObject json = new JSONObject(body);
            JSONObject stats = json.getJSONObject("resources")
                                   .getJSONObject(resource)
                                   .getJSONObject(api);
View Full Code Here

                           .ignoreContentType()
                           .header("Authorization", "Bearer " + accessToken)
                           .header("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8")
                           .header("User-agent", "ripe and zipe")
                           .get();
        String body = doc.body().html().replaceAll(""", "\"");
        Object jsonObj = new JSONTokener(body).nextValue();
        JSONArray statuses;
        if (jsonObj instanceof JSONObject) {
            JSONObject json = (JSONObject) jsonObj;
            if (json.has("errors")) {
View Full Code Here

                    .userAgent(USER_AGENT)
                    .method(Method.POST)
                    .execute();

        Document doc = resp.parse();
        String jsonText = doc.body().html();
        jsonText = jsonText.replace(""""\"");
        System.err.println(jsonText);
        JSONObject json = new JSONObject(jsonText);
        JSONArray pictures = json.getJSONArray("pictures");
        for (int i = 0; i < pictures.length(); i++) {
View Full Code Here

                            .maxBodySize(0)
                            .get();

        // Try to use embedded JSON to retrieve images
        Pattern p = Pattern.compile("^.*Imgur\\.Album\\.getInstance\\((.*)\\);.*$", Pattern.DOTALL);
        Matcher m = p.matcher(doc.body().html());
        if (m.matches()) {
            try {
                JSONObject json = new JSONObject(m.group(1));
                JSONObject jsonAlbum = json.getJSONObject("album");
                ImgurAlbum imgurAlbum = new ImgurAlbum(url, jsonAlbum.getString("title_clean"));
View Full Code Here

            } catch (JSONException e) {
                logger.debug("Error while parsing JSON at " + url + ", continuing", e);
            }
        }
        p = Pattern.compile("^.*= new ImgurShare\\((.*)\\);.*$", Pattern.DOTALL);
        m = p.matcher(doc.body().html());
        if (m.matches()) {
            try {
                ImgurAlbum imgurAlbum = new ImgurAlbum(url);
                JSONObject json = new JSONObject(m.group(1));
                JSONArray images = json.getJSONArray("hashes");
View Full Code Here

                    JOptionPane.ERROR_MESSAGE);
            return;
        } finally {
            configUpdateLabel.setText("Current version: " + getThisJarVersion());
        }
        String jsonString = doc.body().html().replaceAll("&quot;", "\"");
        JSONObject json = new JSONObject(jsonString);
        JSONArray jsonChangeList = json.getJSONArray("changeList");
        StringBuilder changeList = new StringBuilder();
        for (int i = 0; i < jsonChangeList.length(); i++) {
            String change = jsonChangeList.getString(i);
View Full Code Here

    private Element renderedElement;

    public Component(Element elem, AttributesRequire attrs) throws Exception {
        Document doc = new Document("");
        doc.appendElement("body");
        doc.body().appendChild(elem);
        renderedElement = renderTemplate(doc, attrs);
    }

    public Component(Element elem) throws Exception {
        this(elem, null);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.