当前位置: 首页>>代码示例>>Java>>正文


Java Elements类代码示例

本文整理汇总了Java中org.jsoup.select.Elements的典型用法代码示例。如果您正苦于以下问题:Java Elements类的具体用法?Java Elements怎么用?Java Elements使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Elements类属于org.jsoup.select包,在下文中一共展示了Elements类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: loadPendingMateriales

import org.jsoup.select.Elements; //导入依赖的package包/类
public void loadPendingMateriales(final MaterialsCallback callback) {
    String json = "idmat=-1&codasi=-1&expresion=&direccion=&filtro=&pendientes=S";
    UAWebService.HttpWebPostRequest(context, MATERIALES_UNSEEN, json, new UAWebService.WebCallBack() {
        @Override
        public void onNavigationComplete(boolean isSuccessful, String body) {
            if (isSuccessful) {
                Document doc = Jsoup.parse(body);
                //Get Post data
                Elements mensajes = doc.select(MATERIALES_LIST_BODY);
                parseBody(mensajes);
                callback.onResult(true, "");
            } else {
                callback.onResult(false, body);
            }
        }
    });
}
 
开发者ID:Onelio,项目名称:ConnectU,代码行数:18,代码来源:MaterialesRequest.java

示例2: populatePointsGivenToRB

import org.jsoup.select.Elements; //导入依赖的package包/类
public void populatePointsGivenToRB(Team team) {
	int rankCounter = 0;
 		Element rbPointsAllowedTable = rbPointsAllowedURL.select("table").get(1);
 	    Elements rbPointsAllowedRows = rbPointsAllowedTable.select("tr");
 	    
 	    for (int i = 2; i < rbPointsAllowedRows.size(); i++) {
 	    		Element row = rbPointsAllowedRows.get(i);
 	    		Elements cols = row.select("td");
 	    		rankCounter++;
     		
 	    		if(cols.get(0).text().contains(team.getName())) {
 	    			if (cols.get(2).text().contains("*")) {
    				team.setFpToRBRank(rankCounter);
	    			team.setFpToRBAvg(Double.parseDouble(cols.get(18).text()));
	    			break;
    			} else {
	    			team.setFpToRBRank(rankCounter);
	    			team.setFpToRBAvg(Double.parseDouble(cols.get(19).text()));
	    			break;
	    		}
 	    		}
 	    }
}
 
开发者ID:lucci,项目名称:NFLFantasyAnalyzer,代码行数:24,代码来源:WebScraper.java

示例3: getFormMap_Kingo

import org.jsoup.select.Elements; //导入依赖的package包/类
public static Map<String, String> getFormMap_Kingo(String html, int formIndex) {
	Map<String, String> retVal = new HashMap<String, String>();
	try {
		Document doc = Jsoup.parse(html);
		Elements elements = doc.select("form");
		Element formElement = elements.get(formIndex);
		retVal.put("formAction", formElement.attr("action"));
		Elements inputElements = doc.select("input");
		// System.out.println(inputElements);
		for (Element element : inputElements) {
			if (element.nodeName().equals("select")) {
				Element element5 = inputElements.select("option").first();
				retVal.put(element.attr("name"), element5.attr("value"));
			} else {
				if (element.attr("name").equals("") || element.attr("name") == null) {
				} else {
					retVal.put(element.attr("name"), element.attr("value"));
				}
			}
		}
	} catch (Exception e) {
		retVal = null;
	}
	return retVal;
}
 
开发者ID:liaojiacan,项目名称:zhkuas_ssm_maven,代码行数:26,代码来源:HTMLUtil.java

示例4: getURLsFromPage

import org.jsoup.select.Elements; //导入依赖的package包/类
@Override
public List<String> getURLsFromPage(Document doc) {
    List<String> URLs = new ArrayList<>();
    //Pictures
    Elements imgs = doc.select("div.img > img.img-front");
    for (Element img : imgs) {
        String imageURL = img.attr("src");
        imageURL = "https:" + imageURL;
        URLs.add(imageURL);
    }
    //Videos
    Elements vids = doc.select("div.video > video > source");
    for (Element vid : vids) {
        String videoURL = vid.attr("src");
        URLs.add("https:" + videoURL);
    }

    return URLs;
}
 
开发者ID:RipMeApp,项目名称:ripme,代码行数:20,代码来源:EromeRipper.java

示例5: process

import org.jsoup.select.Elements; //导入依赖的package包/类
@Override
public void process(final ExecutionContext executionContext, final Document document)
        throws ProcessException {
    try {
        Elements xkSections = document.getElementsByAttribute(XK_SECTION_ATTR);
        if (xkSections != null) {
            for (Element xkSectionTag : xkSections) {
                Element xkSectionStylesTag = xkSectionTag.getElementsByAttribute(XK_SECTION_STYLES_ATTR).first();
                if (xkSectionStylesTag != null) {
                    String xkSectionStyles = xkSectionStylesTag.attr(XK_SECTION_STYLES_ATTR);
                    xkSectionTag.addClass(xkSectionStyles.trim());
                    xkSectionStylesTag.remove();
                }
            }
        }
    } catch (Exception e) {
        throw new ProcessException(e);
    }
}
 
开发者ID:DantaFramework,项目名称:AEM,代码行数:20,代码来源:XKSectionStylesDOMProcessor.java

示例6: parseProxys

import org.jsoup.select.Elements; //导入依赖的package包/类
@Override
public List<Proxy> parseProxys(String content) {
    Document doc = Jsoup.parse(content);
    Elements elements = doc.select("div#list table tbody tr");
    List<Proxy> proxyList = new ArrayList<>();
    for(Element tr : elements){
        Elements tds = tr.children();
        String ip = tds.get(0).text().trim();
        Integer port = Integer.parseInt(tds.get(1).text());
        proxyList.add(new Proxy(ip,port));
    }
    return proxyList;
}
 
开发者ID:StevenKin,项目名称:ZhihuQuestionsSpider,代码行数:14,代码来源:KuaidailiProxySite.java

示例7: call

import org.jsoup.select.Elements; //导入依赖的package包/类
@Override
public List<SIPNode> call(XpathNode.ScopeEm scopeEm, Elements elements, List<String> args) {
    List<SIPNode> res = new LinkedList<SIPNode>();
    if (elements != null) {
        Pattern pattern = Pattern.compile("\\d+");
        for (Element e : elements) {
            Matcher matcher = pattern.matcher(e.ownText());
            if (matcher.find()) {
                res.add(SIPNode.t(matcher.group()));
            }
        }
    }
    return res;
}
 
开发者ID:virjar,项目名称:sipsoup,代码行数:15,代码来源:NumFunction.java

示例8: meiyuxsCatalog

import org.jsoup.select.Elements; //导入依赖的package包/类
private static Map meiyuxsCatalog(Map map, String url) {
  try {
    List data = new ArrayList();
    Document document = Jsoup
        .connect(url)
        .userAgent(FormatUtil.USER_AGENT_PC)
        .get();
    Element body = document.body();
    Elements catalogEles = body.getElementsByClass("list-group-item");
    for (Element catalogE : catalogEles) {
      if (catalogE.getElementsByTag("a").size() > 0) {
        Map<String, Object> _map = new HashMap<>();
        _map.put("catalog", catalogE.text());
        _map.put("href", "http://www.meiyuxs.com" + catalogE.getElementsByTag("a").first().attr("href"));
        data.add(_map);
      }
    }
    map.put("data", data);
    map.put("cover", "");
    map.put("lastChapter", ((Map) data.get(data.size() - 1)).get("catalog").toString());
  } catch (IOException e) {
    e.printStackTrace();
  }
  return map;
}
 
开发者ID:tomoya92,项目名称:android-apps,代码行数:26,代码来源:JsoupUtil.java

示例9: initRecent

import org.jsoup.select.Elements; //导入依赖的package包/类
/**
 * 最近更新小说列表
 */
private void initRecent(List<FictionModel> list) {

    FictionModel pushTitle = new FictionModel();
    pushTitle.title = TYPE_TITLE_RETCENT;
    pushTitle.type = TYPE_TITLE;
    list.add(pushTitle);

    FictionModel kswHomeModel;
    Elements select = document.select("div#newscontent").select("div.l").select("span.s2").select("a");
    for (Element element : select) {
        kswHomeModel = new FictionModel();
        kswHomeModel.title = element.text();
        kswHomeModel.detailUrl = element.attr("abs:href");
        kswHomeModel.type = TYPE_RECENT;
        list.add(kswHomeModel);
    }

    initAdd(list);
}
 
开发者ID:7449,项目名称:JsoupSample,代码行数:23,代码来源:JsoupFictionHomeManager.java

示例10: getDetailContent

import org.jsoup.select.Elements; //导入依赖的package包/类
@Override
public Map<DetailActivity.parameter, Object> getDetailContent(String baseUrl, String currentUrl, byte[] result, Map<DetailActivity.parameter, Object> resultMap) throws UnsupportedEncodingException {
    List<PicInfo> urls = new ArrayList<>();
    Document document = Jsoup.parse(new String(result, "utf-8"));

    String sTitle = "";
    Elements title = document.select("#header h1");
    if (title.size() > 0)
        sTitle = title.get(0).text();

    List<String> tagList = new ArrayList<>();
    Elements tags = document.select("ul.tagList a");
    if (tags.size() > 0)
        for (Element tag : tags)
            tagList.add(tag.text());

    Elements elements = document.select("ul.gallery li:has(img)");
    for (Element element : elements) {
        urls.add(new PicInfo(element.attr("data-src")).setTitle(sTitle).setTags(tagList));
    }

    resultMap.put(DetailActivity.parameter.CURRENT_URL, currentUrl);
    resultMap.put(DetailActivity.parameter.RESULT, urls);
    return resultMap;
}
 
开发者ID:lanyuanxiaoyao,项目名称:PicKing,代码行数:26,代码来源:AKabe.java

示例11: getImageDetail

import org.jsoup.select.Elements; //导入依赖的package包/类
public List<ImageModel> getImageDetail() {

        List<ImageModel> list = new ArrayList<>();
        ImageModel imageDetailModel;

        Elements select = document.select("div#picture").select("img");
        for (Element element : select) {
            imageDetailModel = new ImageModel();
            imageDetailModel.url = element.attr("src");
            list.add(imageDetailModel);
        }

        return list;
    }
 
开发者ID:7449,项目名称:JsoupSample,代码行数:15,代码来源:JsoupMeiZiTuManager.java

示例12: GetDivContent

import org.jsoup.select.Elements; //导入依赖的package包/类
private static String GetDivContent(Element div) {
    StringBuilder sb = new StringBuilder();
    //考虑div里标签内容的顺序,对div子树进行深度优先搜索
    Stack<Element> sk = new Stack<Element>();
    sk.push(div);
    while (!sk.empty()) {
        //
        Element e = sk.pop();
        //对于div中的div过滤掉
        if (e != div && e.tagName().equals("div")) continue;
        //考虑正文被包含在p标签中的情况,并且p标签里不能含有a标签
        if (e.tagName().equals("p") && e.getElementsByTag("a").size() == 0) {
            String className = e.className();
            if (className.length() != 0 && className.equals("pictext")) continue;
            sb.append(e.text());
            sb.append("\n");
            continue;
        } else if (e.tagName().equals("td")) {
            //考虑正文被包含在td标签中的情况
            if (e.getElementsByTag("div").size() != 0) continue;
            sb.append(e.text());
            sb.append("\n");
            continue;

        }
        //将孩子节点加入栈中
        Elements children = e.children();
        for (int i = children.size() - 1; i >= 0; i--) {
            sk.push((Element) children.get(i));
        }
    }

    return sb.toString();
}
 
开发者ID:xjtushilei,项目名称:ScriptSpider,代码行数:35,代码来源:ContentExtractor.java

示例13: initList

import org.jsoup.select.Elements; //导入依赖的package包/类
/**
 * 最近更新小说列表
 */
private void initList(List<FictionModel> list) {
    FictionModel pushTitle = new FictionModel();
    pushTitle.title = TYPE_TITLE_LIST;
    pushTitle.type = TYPE_TITLE;
    list.add(pushTitle);

    FictionModel kswListModel;
    Elements select = document.select("div#newscontent").select("div.l").select("span.s2").select("a");
    for (Element element : select) {
        kswListModel = new FictionModel();
        kswListModel.title = element.text();
        kswListModel.detailUrl = element.attr("abs:href");
        kswListModel.type = TYPE_UPDATE;
        list.add(kswListModel);
    }

    initAdd(list);
}
 
开发者ID:7449,项目名称:JsoupSample,代码行数:22,代码来源:JsoupFictionListManager.java

示例14: runInSameTime

import org.jsoup.select.Elements; //导入依赖的package包/类
private void runInSameTime(final Element element) throws IOException {
    mExecutorService.submit(new Runnable() {
        @Override
        public void run() {
            String url = element.attr("abs:href");
            try {
                Document document = Jsoup.connect(url)
                        .ignoreContentType(true)
                        .ignoreHttpErrors(true)
                        .userAgent(Url.MOBBILE_AGENT)
                        .get();

                String name = document.select("#okBookShow > div.ok-book-base-info > div.row > div.col-sm-8.ok-book-info > div.ok-book-meta > h1").text();
                String time = "";
                String info = "";
                Elements elements = document.select("#okBookShow > div.ok-book-base-info > div.row > div.col-sm-8.ok-book-info > div.ok-book-meta > div.ok-book-desc > div.ok-book-meta-content").select("p");
                for (int i = 0; i < elements.size(); i++) {


                    if (!elements.get(i).text().equals(""))
                        info = info + elements.get(i).text() + "\n\n";


                }
                String category = document.select("#okBookShow > div.ok-book-base-info > div.row > div.col-sm-8.ok-book-info > div.ok-book-meta > div.ok-book-subjects").text();
                String status = "";
                String author = document.select("#okBookShow > div.ok-book-base-info > div.row > div.col-sm-8.ok-book-info > div.ok-book-meta > div.row > div > div").text();
                String words = "";
                String pic = document.select("#okBookShow > div.ok-book-base-info > div.row > div.col-sm-4 > div > img").attr("abs:src");
                NovelBean no = new NovelBean(name, time, info, category, status, author, words, pic, url);
                list.add(no);
            } catch (IOException e) {
                e.printStackTrace();
            }

            latch.countDown();
        }
    });
}
 
开发者ID:Delsart,项目名称:Bookster,代码行数:40,代码来源:BlahService.java

示例15: call

import org.jsoup.select.Elements; //导入依赖的package包/类
@Override
public List<SIPNode> call(XpathNode.ScopeEm scopeEm, Elements elements, List<String> args) {
    List<SIPNode> res = new LinkedList<SIPNode>();
    if (elements != null && elements.size() > 0) {
        for (Element e : elements) {
            res.add(SIPNode.t(e.html()));
        }
    }
    return res;
}
 
开发者ID:virjar,项目名称:sipsoup,代码行数:11,代码来源:NodeFunction.java


注:本文中的org.jsoup.select.Elements类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。