use of org.jsoup.select.Elements in project EhViewer by seven332.
the class GalleryDetailParser method parseComments.
/**
* Parse comments with html parser
*/
@NonNull
public static GalleryComment[] parseComments(Document document) {
try {
Element cdiv = document.getElementById("cdiv");
Elements c1s = cdiv.getElementsByClass("c1");
List<GalleryComment> list = new ArrayList<>(c1s.size());
for (int i = 0, n = c1s.size(); i < n; i++) {
GalleryComment comment = parseComment(c1s.get(i));
if (null != comment) {
list.add(comment);
}
}
return list.toArray(new GalleryComment[list.size()]);
} catch (Exception e) {
e.printStackTrace();
return EMPTY_GALLERY_COMMENT_ARRAY;
}
}
use of org.jsoup.select.Elements in project EhViewer by seven332.
the class WhatsHotParser method parse.
@SuppressWarnings("ConstantConditions")
public static List<GalleryInfo> parse(String body) throws ParseException {
try {
List<GalleryInfo> galleryInfoList = new ArrayList<>(15);
Document d = Jsoup.parse(body);
Element pp = d.getElementById("pp");
Elements id1List = pp.getElementsByClass("id1");
for (int i = 0, n = id1List.size(); i < n; i++) {
GalleryInfo galleryInfo = new GalleryInfo();
Element id1 = id1List.get(i);
Element id3 = JsoupUtils.getElementByClass(id1, "id3");
Element temp = JsoupUtils.getElementByTag(id3, "a");
String url = temp.attr("href");
GalleryDetailUrlParser.Result result = GalleryDetailUrlParser.parse(url);
galleryInfo.gid = result.gid;
galleryInfo.token = result.token;
temp = JsoupUtils.getElementByTag(temp, "img");
galleryInfo.thumb = EhUtils.handleThumbUrlResolution(temp.attr("src"));
galleryInfo.title = temp.attr("title");
galleryInfo.generateSLang();
galleryInfoList.add(galleryInfo);
}
return galleryInfoList;
} catch (Exception e) {
throw new ParseException("Parse whats hot error", body);
}
}
use of org.jsoup.select.Elements in project charts by vaadin.
the class ChartDesignReaderTest method readConfiguration_enumValueDefinedInFragment_theSameValueIsInConfiguration.
@Test
public void readConfiguration_enumValueDefinedInFragment_theSameValueIsInConfiguration() {
Elements elements = createElements("<legend layout=\"vertical\"></legend>");
Configuration configuration = new Configuration();
ChartDesignReader.readConfigurationFromElements(elements, configuration);
assertEquals(LayoutDirection.VERTICAL, configuration.getLegend().getLayout());
}
use of org.jsoup.select.Elements in project charts by vaadin.
the class ChartDesignReaderTest method readConfiguration_plotOptionsWithReservedTagName_plotOptionsIsAddedToConfiguration.
@Test
public void readConfiguration_plotOptionsWithReservedTagName_plotOptionsIsAddedToConfiguration() {
Elements elements = createElements("<plot-options><chart-area></chart-area></plot-options>");
Configuration configuration = new Configuration();
ChartDesignReader.readConfigurationFromElements(elements, configuration);
assertEquals(1, configuration.getPlotOptions().size());
assertThat(configuration.getPlotOptions(ChartType.AREA), instanceOf(PlotOptionsArea.class));
}
use of org.jsoup.select.Elements in project charts by vaadin.
the class ChartDesignReaderTest method readConfiguration_arrayType_theNewValueIsAddedToArrayInConfiguration.
@Test
public void readConfiguration_arrayType_theNewValueIsAddedToArrayInConfiguration() {
Elements elements = createElements("<plot-options><treemap><levels level=\"1\"></levels></treemap></plot-options>");
Configuration configuration = new Configuration();
ChartDesignReader.readConfigurationFromElements(elements, configuration);
PlotOptionsTreemap lineOptions = (PlotOptionsTreemap) configuration.getPlotOptions(ChartType.TREEMAP);
assertEquals(1, lineOptions.getLevels().length);
assertEquals(1L, lineOptions.getLevels()[0].getLevel());
}
Aggregations