org.jsoup.nodes.Element.getElementById()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(12.1k)|赞(0)|评价(0)|浏览(252)

本文整理了Java中org.jsoup.nodes.Element.getElementById()方法的一些代码示例,展示了Element.getElementById()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Element.getElementById()方法的具体详情如下:
包路径:org.jsoup.nodes.Element
类名称:Element
方法名:getElementById

Element.getElementById介绍

[英]Find an element by ID, including or under this element.

Note that this finds the first matching ID, starting with this element. If you search down from a different starting point, it is possible to find a different element by ID. For unique element by ID within a Document, use Document#getElementById(String)
[中]

代码示例

代码示例来源:origin: seven332/EhViewer

Element gd1 = gm.getElementById("gd1");
try {
  gd.thumb = parseCoverStyle(StringUtils.trim(gd1.child(0).attr("style")));
Element gn = gm.getElementById("gn");
if (null != gn) {
  gd.title = StringUtils.trim(gn.text());
Element gj = gm.getElementById("gj");
if (null != gj) {
  gd.titleJpn = StringUtils.trim(gj.text());
Element gdc = gm.getElementById("gdc");
try {
  String href = gdc.child(0).attr("href");
Element gdn = gm.getElementById("gdn");
if (null != gdn) {
  gd.uploader = StringUtils.trim(gdn.text());
Element gdd = gm.getElementById("gdd");
gd.posted = "";
gd.parent = "";
Element rating_count = gm.getElementById("rating_count");
if (null != rating_count) {
  gd.ratingCount = NumberUtils.parseIntSafely(
Element rating_label = gm.getElementById("rating_label");

代码示例来源:origin: spring-projects/spring-roo

for (Element topMostElement : topMostElements) {
 if (StringUtils.isNotBlank(element.id())
   && topMostElement.getElementById(element.id()) != null) {
  isChildElement = true;
  break;

代码示例来源:origin: stackoverflow.com

String yourXml = ...
Document doc = Jsoup.parse(yourXml, "", Parser.xmlParser()); 
  for (Element person : doc.getElementsByTag("person")) {
    String firstName = person.getElementById("1").text();
    String lastName = person.getElementById("2").text();
  }

代码示例来源:origin: stackoverflow.com

for(Element detailsDate:document.getElementsByClass("fr")){
  newsDate.add(detailsDate.getElementById("newssource").nextElementSibling());
}

代码示例来源:origin: astamuse/asta4d

public Element getElementById(String id) {
  return originElement.getElementById(id);
}

代码示例来源:origin: com.vaadin/flow-server

private Optional<String> addTagName(String id, Field field) {
    idByField.put(field, id);
    Optional<String> tagName = Optional
        .ofNullable(templateRoot.getElementById(id))
        .map(org.jsoup.nodes.Element::tagName);
    if (tagName.isPresent()) {
      tagById.put(id, tagName.get());
    }
    return tagName;
  }
}

代码示例来源:origin: Vegen/SmartCampus

private List<News> getTagNews(Element photoList, String tag, int type){
  List<News> newsList = new ArrayList<>();
  Element focusNews = photoList.getElementById(tag);
  Elements focusLinks = focusNews.getElementsByTag("div").select("#photodiv");
  String text = "";
  for (Element link : focusLinks) {
    Elements photoLink = link.getElementById("photo").getElementsByTag("a");
    Element newsElement = photoLink.get(0);
    String title = newsElement.attr("title");
    String url = newsElement.attr("href");
    String pic = newsElement.getElementsByTag("img").get(0).attr("src");
    String date = link.getElementById("title").ownText();
    text += title + "\n" + url + "\n" + pic + "\n" + date.substring(1, date.length() - 1) + "\n";
    News news = new News(type, title, pic, url, date.substring(1, date.length() - 1));
    newsList.add(news);
  }
  LogUtils.e("HomePresenter", type + "\n" + text);
  return newsList;
}

代码示例来源:origin: burgessjp/GanHuoIO

@Override
  public List<XianDuCategory> apply(@io.reactivex.annotations.NonNull Document document) throws Exception {
    List<XianDuCategory> list = new ArrayList<>();
    Elements elements = document.body().getElementById("xiandu_cat").getElementsByTag("a");
    for (Element element : elements) {
      XianDuCategory item = new XianDuCategory();
      item.setTitle(element.text());
      item.setCategory(element.attr("href").substring(element.attr("href").lastIndexOf("/") + 1));
      list.add(item);
    }
    return list;
  }
});

代码示例来源:origin: Vegen/SmartCampus

private List<News> getTagNews(Element photoList, int type){
  List<News> newsList = new ArrayList<>();
  Elements photodiv = photoList.getElementsByTag("div").select("#photodiv");
  String text = "";
  for (Element link : photodiv) {
    Elements photoLink = link.getElementById("photo").getElementsByTag("a");
    Element newsElement = photoLink.get(0);
    String title = newsElement.attr("title");
    String url = newsElement.attr("href");
    String pic = newsElement.getElementsByTag("img").get(0).attr("src");
    String date = link.getElementById("title").ownText();
    text += title + "\n" + url + "\n" + pic + "\n" + date.substring(1, date.length() - 1) + "\n";
    News news = new News(type, title, pic, url, date.substring(1, date.length() - 1));
    newsList.add(news);
  }
  LogUtils.e("HomePresenter", type + "\n" + text);
  return newsList;
}

代码示例来源:origin: ZhangQinhao/MONKOVEL

private BookInfoBean analyBookinfo(String s, String novelUrl) {
  BookInfoBean bookInfoBean = new BookInfoBean();
  bookInfoBean.setNoteUrl(novelUrl);   //id
  bookInfoBean.setTag(TAG);
  Document doc = Jsoup.parse(s);
  Element resultE = doc.getElementsByClass("box_con").get(0);
  bookInfoBean.setCoverUrl(resultE.getElementById("fmimg").getElementsByTag("img").get(0).attr("src"));
  bookInfoBean.setName(resultE.getElementById("info").getElementsByTag("h1").get(0).text());
  String author = resultE.getElementById("info").getElementsByTag("p").get(0).text().toString().trim();
  author = author.replace(" ", "").replace("  ", "").replace("作者:", "");
  bookInfoBean.setAuthor(author);
  List<TextNode> contentEs = resultE.getElementById("intro").textNodes();
  StringBuilder content = new StringBuilder();
  for (int i = 0; i < contentEs.size(); i++) {
    String temp = contentEs.get(i).text().trim();
    temp = temp.replaceAll(" ", "").replaceAll(" ", "");
    if (temp.length() > 0) {
      content.append("\u3000\u3000" + temp);
      if (i < contentEs.size() - 1) {
        content.append("\r\n");
      }
    }
  }
  bookInfoBean.setIntroduce(content.toString());
  bookInfoBean.setChapterUrl(novelUrl);
  bookInfoBean.setOrigin("gxwztv.com");
  return bookInfoBean;
}

代码示例来源:origin: wzmyyj/ZYMK

private static MuBean getMu(Element element) {
  Element update = element.getElementById("updateTime");
  long time = Long.parseLong(update.attr("datetime"));
  String time_desc = update.text();

代码示例来源:origin: ZhangQinhao/MONKOVEL

private BookInfoBean analyBookinfo(String s, String novelUrl) {
  BookInfoBean bookInfoBean = new BookInfoBean();
  bookInfoBean.setNoteUrl(novelUrl);   //id
  bookInfoBean.setTag(TAG);
  Document doc = Jsoup.parse(s);
  Element resultE = doc.getElementsByClass("panel panel-warning").get(0);
  bookInfoBean.setCoverUrl(resultE.getElementsByClass("panel-body").get(0).getElementsByClass("img-thumbnail").get(0).attr("src"));
  bookInfoBean.setName(resultE.getElementsByClass("active").get(0).text());
  bookInfoBean.setAuthor(resultE.getElementsByClass("col-xs-12 list-group-item no-border").get(0).getElementsByTag("small").get(0).text());
  Element introduceE = resultE.getElementsByClass("panel panel-default mt20").get(0);
  String introduce = "";
  if (introduceE.getElementById("all") != null) {
    introduce = introduceE.getElementById("all").text().replace("[收起]", "");
  } else {
    introduce = introduceE.getElementById("shot").text();
  }
  bookInfoBean.setIntroduce("\u3000\u3000" + introduce);
  bookInfoBean.setChapterUrl(TAG + resultE.getElementsByClass("list-group-item tac").get(0).getElementsByTag("a").get(0).attr("href"));
  bookInfoBean.setOrigin("gxwztv.com");
  return bookInfoBean;
}

代码示例来源:origin: slartus/4pdaClient-plus

public static ArrayList<DevModel> parseModels(IHttpClient client, String brandUrl) throws Throwable {
  ArrayList<DevModel> res = new ArrayList<>();
  String pageBody = client.performGet(brandUrl + "/all");
  Document doc = Jsoup.parse(pageBody);
  Elements con = doc.selectFirst("div.device-frame").getElementById("device-brand-items-list").children();
  for (int i = 0; i < con.size(); i++) {
    Element box = con.get(i).selectFirst("div.box-holder");
    if (box != null) {
      String link = box.selectFirst("a").attr("href");
      String title = box.selectFirst("a").attr("title");
      String image = box.selectFirst("img").attr("src");
      DevModel model = new DevModel(link, title);
      model.setImgUrl(image);
      model.setDescription(box.select(".frame .specifications-list").first().text());
      res.add(model);
    }
  }
  return res;
}

代码示例来源:origin: Yasic/DiyCodeForAndroid

String replyInfo;
String startNumber;
Element replies = colmdElements.get(0).getElementById("replies");
Elements itemPanelBody = replies.select("div.items");
Elements replyElements = itemPanelBody.get(0).getElementsByClass("reply");

代码示例来源:origin: Vegen/SmartCampus

newsForm.put("__EVENTVALIDATION", __EVENTVALIDATION);
Element photoList = body.getElementById("ListNews").getElementById("leftbox").getElementById("photolist");
List<News> newsList = getTagNews(photoList, newsType);

代码示例来源:origin: Vegen/SmartCampus

newsForm.put("__EVENTVALIDATION", __EVENTVALIDATION);
Element photoList = body.getElementById("ListNews").getElementById("leftbox").getElementById("photolist");
List<News> newsList = getTagNews(photoList, newsType);

代码示例来源:origin: Vegen/SmartCampus

.subscribe(document -> {
  Element body = document.body();
  Element photoList = body.getElementById("ListNews").getElementById("leftbox").getElementById("photolist");

代码示例来源:origin: XunMengWinter/Now

PrefUtil.setRefreshTime(Constants.KEY_REFRESH_TIME_ZCOOL, new Date().getTime());
Element userWorks = document.body().getElementById("user-works");

代码示例来源:origin: Kaysoro/KaellyBot

public static Monster getMonster(Language lg, String url) throws IOException {
  Document doc = JSoupManager.getDocument(url);
  String name = doc.getElementsByClass("ak-return-link").first().text();
  String level = doc.getElementsByClass("ak-encyclo-detail-level").first().text()
      .replaceAll(Translator.getLabel(lg, "monster.extract.level") + " ", "");
  String family = doc.getElementsByClass("ak-encyclo-detail-type").last().children().last().text();
  Element element = doc.getElementsByClass("ak-encyclo-detail-illu").first().getElementsByTag("img").first();
  String skinURL = element.attr("data-src");
  String caracteristics = null;
  String resistances = null;
  String zones = null;
  List<String> butins = new ArrayList<>();
  List<String> butinsConditionne = new ArrayList<>();
  boolean error = false;
  Elements titles = doc.getElementsByClass("ak-panel-title");
  for (Element title : titles)
    if (title.text().equals(Translator.getLabel(lg, "monster.extract.caracteristic")))
      caracteristics = extractStatsFromTitle(lg, title);
    else if (title.text().equals(Translator.getLabel(lg, "monster.extract.resistance")))
      resistances = extractStatsFromTitle(lg, title);
    else if (title.text().equals(Translator.getLabel(lg, "monster.extract.zones")))
      zones = title.parent().children().last().text();
    else if (title.text().equals(Translator.getLabel(lg, "monster.extract.butins")))
      error = error || extractButins(butins, title.parent()
          .getElementById("ak-encyclo-monster-drops ak-container ak-content-list"));
    else if (title.text().equals(Translator.getLabel(lg, "monster.extract.butins_conditionnes")))
      error = error || extractButins(butinsConditionne, title.parent());
  return new Monster(name, family, level, caracteristics, URLManager.abs(skinURL), url, resistances, zones, butins, butinsConditionne, error);
}

代码示例来源:origin: XunMengWinter/Now

PrefUtil.setRefreshTime(Constants.KEY_REFRESH_TIME_MOMENT, new Date().getTime());
Element userWorks = document.body().getElementById("selection");
if (userWorks == null) return;
for (Element element : userWorks.select("li")) {

相关文章

Element类方法