Package org.jsoup.nodes

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


        // double check, no charset, falls back to utf8 which is incorrect
        in = getFile("/htmltests/meta-charset-2.html"); //
        doc = Jsoup.parse(in, null, "http://example.com"); // gb2312, no charset
        assertEquals("UTF-8", doc.outputSettings().charset().displayName());
        assertFalse("新".equals(doc.text()));

        // confirm fallback to utf8
        in = getFile("/htmltests/meta-charset-3.html");
        doc = Jsoup.parse(in, null, "http://example.com/"); // utf8, no charset
        assertEquals("UTF-8", doc.outputSettings().charset().displayName());
View Full Code Here


        // confirm fallback to utf8
        in = getFile("/htmltests/meta-charset-3.html");
        doc = Jsoup.parse(in, null, "http://example.com/"); // utf8, no charset
        assertEquals("UTF-8", doc.outputSettings().charset().displayName());
        assertEquals("新", doc.text());
    }

    @Test
    public void testBrokenHtml5CharsetWithASingleDoubleQuote() throws IOException {
        InputStream in = inputStreamFrom("<html>\n" +
View Full Code Here

        String url = "http://direct.infohound.net/tools/bad-charset.pl";
        Connection.Response res = Jsoup.connect(url).execute();
        assertEquals("text/html; charset=UFT8", res.header("Content-Type")); // from the header
        assertEquals(null, res.charset()); // tried to get from header, not supported, so returns null
        Document doc = res.parse(); // would throw an error if charset unsupported
        assertTrue(doc.text().contains("Hello!"));
        assertEquals("UTF-8", res.charset()); // set from default on parse
    }

    @Test
    public void maxBodySize() throws IOException {
View Full Code Here

        } finally {
            stream.close();
        }

        Document out = res.parse();
        assertTrue(out.text().contains("HTML Tidy Complete"));
    }

    /**
     * Tests upload of binary content to a remote service.
     */
 
View Full Code Here

class Html2Text {
  public String text(String html, String cssSelector) {
    Document doc = Jsoup.parse(html);

    if (cssSelector == null) {
      return doc.text();
    }
    else {
      return doc.select(cssSelector).text();
    }
  }
View Full Code Here

  protected String stripHtml(String value) {
    if (value == null || value.trim().isEmpty())
      return value;
    Document doc = Jsoup.parse(value);
    return doc.text();
  }

  public String getFieldSource() {
    return fieldSource;
  }
View Full Code Here

      conn.cookie("PcAicaip", "3307f%2FVmMBYVuaqdGe8QIi6otjFMA7yaPM%2Bh%2Fg3Gk1K2o4VadpS%2B3dFciwhDSxqYTnA%2F9KqvHrt0JECP3pc%2FxksZwewPkoJ27ZVdjXs2cxaWKmKLyLx5ljyn%2B%2Bitpg%2FqWq6yvHP%2FCypVgdU%2BBntiEGYC%2BYvrSrb83V7ceawUHWE");
      conn.cookie("PcAicain", "haha");
      conn.cookie("playTimes06481010C78141AB89F3EBBC43A1E9A9", "0");
      conn.cookie("5pao_VID_06481010C78141AB89F3EBBC43A1E9A9", "true");
      Document doc = conn.post();
      String res = doc.text();
      res = res.substring(res.indexOf("{"), res.indexOf("}")+1);
      JSONObject obj = JSONObject.fromObject(res);
      String title = obj.getString("title");
      String numbers = obj.getString("numbers");
     
View Full Code Here

      conn.cookie("PcAicaip", "3307f%2FVmMBYVuaqdGe8QIi6otjFMA7yaPM%2Bh%2Fg3Gk1K2o4VadpS%2B3dFciwhDSxqYTnA%2F9KqvHrt0JECP3pc%2FxksZwewPkoJ27ZVdjXs2cxaWKmKLyLx5ljyn%2B%2Bitpg%2FqWq6yvHP%2FCypVgdU%2BBntiEGYC%2BYvrSrb83V7ceawUHWE");
      conn.cookie("PcAicain", "haha");
      conn.cookie("playTimes06481010C78141AB89F3EBBC43A1E9A9", "0");
      conn.cookie("5pao_VID_06481010C78141AB89F3EBBC43A1E9A9", "true");
      doc = conn.post();
      res = doc.text();
      res = res.substring(res.indexOf("{"), res.indexOf("}")+1);
      obj = JSONObject.fromObject(res);
      title = obj.getString("title");
      numbers = obj.getString("numbers");
      System.out.println("JX>>> "+title+": "+numbers);
View Full Code Here

  public void getIsPullData(String url,String id) {//100 BLSSC
    try {
      Connection conn = ConnectionManager.getInstance().getConnection(url);
      conn.cookie("id", id).data("id",id,"page","1","rows","10");
      Document doc = conn.post();
      String res = doc.text();
      JSONObject obj = JSONObject.fromObject(res);
      int total = obj.getInt("total");
      System.out.println("^^^^^^total:"+total +"  lastPullCount:"+lastPullCount+"~~~~~"+format.format(new Date()));
      isPullData = total != lastPullCount;
      lastPullCount = total;
View Full Code Here

    try {
      XmlUtils utils = new XmlUtils();
      Connection conn = ConnectionManager.getInstance().getConnection(url);
      conn.cookie("id", id).data("id",id,"page",""+pageNo,"rows","10");
      Document doc = conn.post();
      String res = doc.text();
      JSONObject obj = JSONObject.fromObject(res);
      int total = obj.getInt("total");
      int count = 0;
      boolean skipout = false;
      do {
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.