Package org.jsoup.nodes

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


    extractStyles(doc);
    applyStyles(doc);
    inlineImages(doc);

    doc.outputSettings(doc.outputSettings().prettyPrint(false).escapeMode(Entities.EscapeMode.xhtml));
    String output = doc.outerHtml();
    return output;
  }

  /**
   * Inlines images marked with <code>data-inline="true"</code>
View Full Code Here


            setupStandaloneDocument(context, pageResponse);
            context.getSession().modifyBootstrapResponse(pageResponse);

            sendBootstrapHeaders(response, headers);

            return document.outerHtml();
        } else {
            StringBuilder sb = new StringBuilder();
            for (Node node : fragmentResponse.getFragmentNodes()) {
                if (sb.length() != 0) {
                    sb.append('\n');
View Full Code Here

        }

        Document res = new Document( "" );
        res.appendChild( body.select( "div[id=main]" ).first() );

        resp.getOutputStream().write( res.outerHtml().getBytes() );

    }
}
View Full Code Here

   
    public static String getVideoURLAtPage(String url) throws IOException {
        Document doc = Http.url(url)
                           .userAgent(USER_AGENT)
                           .get();
        String html = doc.outerHtml();
        String videoURL = null;
        for (String quality : new String[] {"1080", "720", "480", "240"}) {
            quality = "url" + quality + "\\\":\\\"";
            if (html.contains(quality)) {
                videoURL = html.substring(html.indexOf(quality) + quality.length());
View Full Code Here

                String u = this.url.toExternalForm();
                Document doc = Http.url(u)
                                   .referrer(u)
                                   .get();
                Pattern p = Pattern.compile("^.*__fileurl = '([^']{1,})';.*$", Pattern.DOTALL);
                Matcher m = p.matcher(doc.outerHtml());
                if (m.matches()) {
                    String file = m.group(1);
                    String prefix = "";
                    if (Utils.getConfigBoolean("download.save_order", true)) {
                        prefix = String.format("%03d_", index);
View Full Code Here

        }

        Document res = new Document( "" );
        res.appendChild( body.select( "div[id=main]" ).first() );

        resp.getOutputStream().write( res.outerHtml().getBytes() );

    }
}
View Full Code Here

    @Test public void handlesXmlDeclarationAsDeclaration() {
        String html = "<?xml encoding='UTF-8' ?><body>One</body><!-- comment -->";
        Document doc = Jsoup.parse(html, "", Parser.xmlParser());
        assertEquals("<?xml encoding='UTF-8' ?> <body> One </body> <!-- comment -->",
                StringUtil.normaliseWhitespace(doc.outerHtml()));
        assertEquals("#declaration", doc.childNode(0).nodeName());
        assertEquals("#comment", doc.childNode(2).nodeName());
    }

    @Test public void xmlFragment() {
View Full Code Here

    @Test public void handlesXmlDeclarationAsDeclaration() {
        String html = "<?xml encoding='UTF-8' ?><body>One</body><!-- comment -->";
        Document doc = Jsoup.parse(html, "", Parser.xmlParser());
        assertEquals("<?xml encoding='UTF-8' ?> <body> One </body> <!-- comment -->",
                StringUtil.normaliseWhitespace(doc.outerHtml()));
        assertEquals("#declaration", doc.childNode(0).nodeName());
        assertEquals("#comment", doc.childNode(2).nodeName());
    }

    @Test public void xmlFragment() {
View Full Code Here

   
      Document srcDoc = Jsoup.connect(baseUri + "srcPage").get();
      Document dstDoc = Jsoup.connect(baseUri + "dstPage").get();

      // pages should render exactly identical
      assertEquals(srcDoc.outerHtml(), dstDoc.outerHtml());

      tx.success();

    } catch (Exception ex) {
      ex.printStackTrace();
View Full Code Here

    try (final Tx tx = app.tx()) {

      Document parsedDocument = Jsoup.connect(baseUri + name).get();

      System.out.println(parsedDocument.outerHtml());

      assertEquals("user1", parsedDocument.select("html > body > b > p").get(0).ownText());
      assertEquals("user2", parsedDocument.select("html > body > b > p").get(1).ownText());
      assertEquals("user3", parsedDocument.select("html > body > b > p").get(2).ownText());
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.