use of org.jsoup.select.Elements in project charts by vaadin.
the class ChartDesignReaderTest method readConfiguration_multiValueNodes_allTheNodesAreInTheConfiguration.
@Test
public void readConfiguration_multiValueNodes_allTheNodesAreInTheConfiguration() {
Elements elements = createElements("<y-axis><chart-title>First</chart-title></y-axis>" + "<y-axis><chart-title>Second</chart-title></y-axis>");
Configuration configuration = new Configuration();
ChartDesignReader.readConfigurationFromElements(elements, configuration);
assertEquals(2, configuration.getyAxes().getNumberOfAxes());
assertEquals("First", configuration.getyAxis(0).getTitle().getText());
assertEquals("Second", configuration.getyAxis(1).getTitle().getText());
}
use of org.jsoup.select.Elements in project mzzb-server by mingzuozhibi.
the class SakuraSpeedSpider method fetch.
public void fetch() throws IOException {
Document document = Jsoup.connect(SAKURA_SPEED_URL).timeout(30000).get();
Elements tables = document.select("table");
Elements fonts = document.select("b>font[color=red]");
for (int i = 0; i < tables.size(); i++) {
updateSakura(tables.get(i), fonts.get(i).text());
}
}
use of org.jsoup.select.Elements in project Palm300Heroes by nicolite.
the class NewsModel method getTyBannerNiang.
public static List<NewsBanner> getTyBannerNiang(Document document) {
List<NewsBanner> list = new ArrayList<>();
Elements niang = document.body().getElementsByClass("niang");
Elements img = niang.select("img");
Elements a = niang.select("a");
for (int i = 0; i < Math.min(a.size(), img.size()); i++) {
NewsBanner newsBanner = new NewsBanner();
newsBanner.setUrl(a.get(i).attr("abs:href"));
String url = img.get(i).attr("style").replace("background: url(", "").replace(") no-repeat center;", "").trim();
newsBanner.setImage(url);
newsBanner.setTitle(" ");
list.add(newsBanner);
}
return list;
}
use of org.jsoup.select.Elements in project Palm300Heroes by nicolite.
the class NewsModel method getTYAVideoContent.
public static String getTYAVideoContent(Document document) {
Element body = document.body();
Element head = document.head();
Elements inner = body.getElementsByClass("inner");
Elements images = inner.select("img[src]");
for (Element element : images) {
element.removeAttr("style");
element.attr("src", element.attr("abs:src"));
}
Elements span = inner.select("span");
for (Element element : span) {
element.removeAttr("style");
}
Elements p = inner.select("p");
for (Element element : p) {
element.removeAttr("style");
}
Elements div = inner.select("div");
for (Element element : div) {
element.removeAttr("style");
}
Elements h1 = inner.select("h1");
for (Element element : h1) {
element.removeAttr("style");
}
Elements h2 = inner.select("h2");
for (Element element : h2) {
element.removeAttr("style");
}
Elements h3 = inner.select("h3");
for (Element element : h3) {
element.removeAttr("style");
}
Elements h4 = inner.select("h4");
for (Element element : h4) {
element.removeAttr("style");
}
Elements h5 = inner.select("h5");
for (Element element : h5) {
element.removeAttr("style");
}
Elements h6 = inner.select("h6");
for (Element element : h6) {
element.removeAttr("style");
}
head.empty();
head.append(" <meta charset=\"utf-8\">" + "<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\">" + "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">" + "<style type=\"text/css\">img{width: 100%; height: 100%; object-fit: contain}</style>");
body.empty();
body.append(inner.toString());
String html = document.toString().replace("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">", "<!DOCTYPE html>").replace("xmlns=\"http://www.w3.org/1999/xhtml\"", "");
LogUtils.d(TAG, html);
return html;
}
use of org.jsoup.select.Elements in project Palm300Heroes by nicolite.
the class NewsModel method getTYBannerA.
// http://300c.jumpw.com/
public static List<NewsBanner> getTYBannerA(Document document) {
List<NewsBanner> list = new ArrayList<>();
Elements ad_gd = document.body().getElementsByClass("ad_gd");
Elements a = ad_gd.select("a");
Elements img = ad_gd.select("img");
for (int i = 0; i < Math.min(a.size(), img.size()); i++) {
NewsBanner newsBanner = new NewsBanner();
newsBanner.setUrl(a.get(i).attr("abs:href"));
String url = img.get(i).attr("style").replace("background: url(", "").replace(") no-repeat center;", "").trim();
newsBanner.setImage(url);
newsBanner.setTitle(" ");
list.add(newsBanner);
}
return list;
}
Aggregations