Here you can find the source of getExplanation(String html)
public static String getExplanation(String html)
//package com.java2s; /*//w w w .j a v a 2s . com Copyright 2015 Joseph Tranquillo {name of copyright owner} Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ import org.jsoup.Jsoup; public class Main { private static final String EXPLANATION = "Explanation:"; private static final String TOMORROWS_PIC = "Tomorrow's picture"; private static final String WE_KEEP_AN_ARCHIVE = "We keep an archive"; public static String getExplanation(String html) { String text = Jsoup.parse(html).text(); int indexof_explanation = -1; int indexof_tomorrowspic = -1; int indexof_wekeepanarchive = -1; indexof_explanation = text.indexOf(EXPLANATION); indexof_tomorrowspic = text.indexOf(TOMORROWS_PIC); indexof_wekeepanarchive = text.indexOf(WE_KEEP_AN_ARCHIVE); if (indexof_explanation == -1 || (indexof_tomorrowspic == -1 && indexof_wekeepanarchive == -1)) { return null; } String explanation = null; if (indexof_tomorrowspic != -1) { explanation = text.substring(1 + indexof_explanation + EXPLANATION.length(), indexof_tomorrowspic); } else if (indexof_wekeepanarchive != -1) { explanation = text.substring(1 + indexof_explanation + EXPLANATION.length(), indexof_wekeepanarchive); } explanation = explanation.replace("\n", " "); explanation = explanation.replace("[s]+", " "); explanation = explanation.trim(); return explanation; } }