Java Code Examples for org.jsoup.parser.Parser#setTrackErrors()

The following examples show how to use org.jsoup.parser.Parser#setTrackErrors() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ParserCorrectorTest.java    From jsoup-learning with MIT License 5 votes vote down vote up
public static void main(String[] args) {
    String htmlWithDivUnclosed = "<body>\n" +
            " <textarea>\n" +
            "        &lt;!-- Text --&gt;\n" +
            "        xxx\n" +
            "    </textarea> \n" +
            " <div> \n" +
            " <div>\n" +
            "  <table> \n" +
            "   <!-- InTable --> \n" +
            "   <!-- InTableText --> xxx \n" +
            "   <tbody> \n" +
            "    <tr> \n" +
            "     <!-- InRow --> \n" +
            "     <td> \n" +
            "      <!-- InCell --> </td> \n" +
            "    </tr> \n" +
            "   </tbody> \n" +
            "  </table> \n" +
            " </div> \n" +
            "</body>";
    Parser parser = Parser.htmlParser();
    parser.setTrackErrors(100);
    Document document = parser.parseInput(htmlWithDivUnclosed, "");
    List<ParseError> errors = parser.getErrors();
    System.out.println(errors);

}
 
Example 2
Source File: PageErrorChecker.java    From jsoup-learning with MIT License 5 votes vote down vote up
public static List<ParseError> check(String url) throws IOException {
    Parser parser = Parser.htmlParser();
    parser.setTrackErrors(100);
    String body = Jsoup.connect(url).userAgent("Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.95 Safari/537.36")
            .execute().body();
    parser.parseInput(body, url);
    List<ParseError> errors = parser.getErrors();
    return errors;
}