當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。