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


Java Elements.isEmpty方法代码示例

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


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

示例1: getVidStreamingVideo

import org.jsoup.select.Elements; //导入方法依赖的package包/类
private String getVidStreamingVideo(String url) {
    String videoUrl = "";
    try {
        Document docdata = Jsoup.connect(url).userAgent(getUserAgent())
                .referrer("http://www.google.com")
                .timeout(Parser.getParseTimeOut()).get();
        Elements eles = docdata.select("div[class=videocontent]").select("video[id=my-video-player]").select("source");
        String tempUrl = "";
        if (eles != null && !eles.isEmpty()) {
            for (Element ele : eles) {
                tempUrl = ele.attr("abs:src");
                if (!TextUtils.isEmpty(tempUrl))
                    videoUrl = tempUrl;
            }
        } else {
            eles = docdata.select("div[class=videocontent]").select("iframe");
            if (eles != null && !eles.isEmpty()) {
                videoUrl = eles.attr("src");
                return getVideoFromProvider(videoUrl);
            }
        }
    } catch (IOException e) {
        WriteLog.appendLog(Log.getStackTraceString(e));
    }
    return videoUrl;
}
 
开发者ID:SalmanTKhan,项目名称:MyAnimeViewer,代码行数:27,代码来源:Parser.java

示例2: getSafeUploadVideo

import org.jsoup.select.Elements; //导入方法依赖的package包/类
public String getSafeUploadVideo(String url) {
    //http://www.safeupload.org/getembed/f93fb4096e0875979215c0307dd53ff5
    String lVideoUrl = "";
    try {
        Document docdata = Jsoup.connect(url).userAgent(mUserAgent)
                .referrer("http://www.google.com")
                .timeout(Parser.getParseTimeOut()).get();
        Elements eles = docdata.select("body").select("div + script");
        if (eles != null && !eles.isEmpty()) {
            lVideoUrl = eles.get(eles.size() - 2).html();
            if (!TextUtils.isEmpty(lVideoUrl)) {
                final Pattern pattern = Pattern.compile("'file': '(.+?)'");
                final Matcher matcher = pattern.matcher(lVideoUrl);
                matcher.find();
                lVideoUrl = matcher.group(1);
            }
        }
    } catch (IOException e) {
        WriteLog.appendLog(Log.getStackTraceString(e));
    }
    return lVideoUrl;
}
 
开发者ID:SalmanTKhan,项目名称:MyAnimeViewer,代码行数:23,代码来源:Parser.java

示例3: getBandsFromSearchPage

import org.jsoup.select.Elements; //导入方法依赖的package包/类
private List<Band> getBandsFromSearchPage(String pageLink, boolean asynchronous) throws Exception
{
	Document searchPage = HttpUtil.getDocument(pageLink);
	Elements bandLinks = searchPage.select("div[class*=itemurl]");
	bandLinks = JSONUtil.getBandTypes(bandLinks, FilterType.ARTIST);
	logger.debug("Band links to process: " + bandLinks.size());
	if(bandLinks != null && !bandLinks.isEmpty())
	{
		List<Band> bandList;
		if(asynchronous)
		{
			bandList = processBandAsynchronous(bandLinks);
		}
		else
		{
			bandList = new ArrayList<Band>();
			for(Element divURL : bandLinks)
			{
				String bandURL = divURL.select("a").first().text();
				Band band = processBand(bandURL);
				if(band != null)
				{
					logger.debug("Processing band on single thread: " + bandURL);
					bandList.add(band);
				}
			}
		}
		return bandList;
	}
	return null;
}
 
开发者ID:scriptkittie,项目名称:bandcamp-api,代码行数:32,代码来源:BandcampAPI.java

示例4: getSingleQueryResult

import org.jsoup.select.Elements; //导入方法依赖的package包/类
private static String getSingleQueryResult(Document soup, String query, boolean toString){
    Elements re = soup.select(query);
    if(!re.isEmpty()){
        if(toString){
            return re.get(0).toString();
        }else {
            return re.get(0).text();
        }
    }else{
        return "";
    }
}
 
开发者ID:mmjang,项目名称:quiz_helper,代码行数:13,代码来源:Mnemonic.java

示例5: extractDates

import org.jsoup.select.Elements; //导入方法依赖的package包/类
@NonNull
private String extractDates(@NonNull Element article) {
    StringBuilder builder = new StringBuilder("");
    Elements datePublished = article.select("[itemprop='datePublished']");
    if (!datePublished.isEmpty()) {
        builder.append("Publié le ")
                .append(datePublished.first().text());
    }
    Elements dateModified = article.select("[itemprop='dateModified']");
    if (!dateModified.isEmpty()) {
        builder.append(", modifié le ")
                .append(dateModified.first().text());
    }
    return builder.toString();
}
 
开发者ID:MBach,项目名称:LeMondeRssReader,代码行数:16,代码来源:ArticleActivity.java

示例6: getSingleQueryResult

import org.jsoup.select.Elements; //导入方法依赖的package包/类
private static String getSingleQueryResult(Element soup, String query, boolean toString){
    Elements re = soup.select(query);
    if(!re.isEmpty()){
        if(toString) {
            return re.get(0).toString();
        }
        else{
            return re.get(0).text();
        }
    }else{
        return "";
    }
}
 
开发者ID:mmjang,项目名称:ankihelper,代码行数:14,代码来源:VocabCom.java

示例7: getDishesFromRow

import org.jsoup.select.Elements; //导入方法依赖的package包/类
private Stream<Dish> getDishesFromRow(Element row, int rowIndex, LocalDate baseDate, String mensaId) {
	Elements categoryCell = row.select("th");
	Elements dishCells = row.select("td");
	if (!categoryCell.isEmpty() && dishCells.size() == 5) {
		String category = StringUtils.defaultString(categoryCell.get(0).text());
		AtomicInteger dayIndex = new AtomicInteger(0);
		return dishCells.stream().flatMap(cell -> getDishesFromCell(cell, category, rowIndex, baseDate.plusDays(dayIndex.getAndIncrement()), mensaId));
	}
	return Stream.empty();
}
 
开发者ID:xabgesagtx,项目名称:mensa-api,代码行数:11,代码来源:MenuWeekScraper.java

示例8: getSingleQueryResult

import org.jsoup.select.Elements; //导入方法依赖的package包/类
private static String getSingleQueryResult(Element soup, String query){
    Elements re = soup.select(query);
    if(!re.isEmpty()){
        return re.get(0).text();
    }else{
        return "";
    }
}
 
开发者ID:mmjang,项目名称:quiz_helper,代码行数:9,代码来源:YoudaoOnline.java

示例9: parsePedigree

import org.jsoup.select.Elements; //导入方法依赖的package包/类
/**
 * Converts an offsprings {@link Document} into {@link Pedigree}'s.
 *
 * @param offspringsDocument
 *            HTML document with the offspring results content
 * @return a {@link List} of {@link Pedigree} representing the
 *         parsed pedigree results
 */
public Optional<Pedigree> parsePedigree(Document pedigreeDocument) {

	Elements pedigreeTable = pedigreeDocument.select("table.pedigree");
	if (pedigreeTable.isEmpty()) {
		// there is no pedigree for the specified id
		LOGGER.info("Pedigree not found for the specified id");
		return Optional.empty();
	}

	Pedigree pedigree = new Pedigree();
	// parse id
	pedigree.setId(getIdFromAnchor(pedigreeDocument.select("p.subnavbar a").first()));
	pedigree.setDob(getDob(pedigreeDocument));
	pedigree.setName(getName(pedigreeDocument));
	pedigree.setEms(getEms(pedigreeDocument));
	pedigree.setGender(getGender(pedigreeDocument));
	pedigree.setNationalityCountryCode(getNationalityCountryCode(pedigreeDocument));
	pedigree.setLocationCountryCode(getLocationyCountryCode(pedigreeDocument));
	pedigree.setInbreeding(getInbreeding(pedigreeDocument));

	// set parent id's
	getParentId(pedigreeDocument, Gender.M).ifPresent(pedigree::setSireId);
	getParentId(pedigreeDocument, Gender.F).ifPresent(pedigree::setDamId);

	LOGGER.debug("Pedigree found {}", pedigree);
	return Optional.of(pedigree);
}
 
开发者ID:padriano,项目名称:catpeds,代码行数:36,代码来源:PawpedsDocumentParser.java

示例10: syncStockInfos

import org.jsoup.select.Elements; //导入方法依赖的package包/类
@PostMapping("/stock-infos/sync")
@ResponseStatus(HttpStatus.OK)
public void syncStockInfos() throws IOException {
	Document doc = Jsoup.connect(ConfigConstant.STOCK_INFO_URL).get();
	Element element = doc.getElementById("quotesearch");
	Elements ulElements = element.select("ul");
	for (Element ulElement : ulElements) {
		Elements liElements = ulElement.select("li");
		for (Element liElement : liElements) {
			Elements children = liElement.children();
			if (!children.isEmpty()) {
				String stockInfo = children.get(0).text();
				if (ObjectUtils.isNotEmpty(stockInfo)) {
					stockInfo = stockInfo.substring(0, stockInfo.length() - 1);
					String[] stockInfos = stockInfo.split("\\(");
					String stockName = stockInfos[0];
					String stockCode = stockInfos[1];
					if (stockCode.startsWith(ConfigConstant.SH_STOCK_PRE)) {
						saveStockInfo(stockCode, stockName, ConfigConstant.STOCK_TYPE_SH);
					} else if (stockCode.startsWith(ConfigConstant.SZ_STOCK_PRE)) {
						saveStockInfo(stockCode, stockName, ConfigConstant.STOCK_TYPE_SZ);
					} else if (stockCode.startsWith(ConfigConstant.CY_STOCK_PRE)) {
						saveStockInfo(stockCode, stockName, ConfigConstant.STOCK_TYPE_SZ);
					}
				}
			}
		}
	}
}
 
开发者ID:wengwh,项目名称:plumdo-stock,代码行数:30,代码来源:StockInfoSyncResource.java

示例11: getStreamangoVideo

import org.jsoup.select.Elements; //导入方法依赖的package包/类
public String getStreamangoVideo(String url) {
    String lVideoUrl = "";
    try {
        Document docdata = Jsoup.connect(url).userAgent(mUserAgent)
                .referrer("http://www.google.com")
                .timeout(Parser.getParseTimeOut()).get();
        Elements eles = null;
        if (!url.contains("embed")) {
            eles = docdata.select("div[class=leftcol]").select("iframe");
            if (eles != null && !eles.isEmpty()) {
                url = eles.get(0).attr("src");
                return getMP4UploadComVideo(url);
            }
        } else {
            eles = docdata.select("div[class=videocontainer] + script");
            Pattern p = Pattern.compile("http(s)?://([\\w-]+.)+[\\w-]+(/[\\w- ./?%&=])?", Pattern.CASE_INSENSITIVE | Pattern.DOTALL);

            String innerHtml = "";
            String videoUrl = "";
            for (int i = 0; i < eles.size(); i++) {
                innerHtml = eles.get(i).html();
                String[] innerHtmlSplit = innerHtml.split("\n");
                for (String s : innerHtmlSplit) {
                    //https://streamango.com/v/d/lnorrkmcdnacnqsa~1500704504~108.21.0.0~uJnSFqaq/720
                    if (!s.contains("video/mp4"))
                        continue;
                    s = s.replace("srces.push({type:\"video/mp4\",src:\"", "https:").trim();
                    lVideoUrl = s.substring(0, s.lastIndexOf("\""));
                    break;
                }
            }
        }
    } catch (IOException e) {
        WriteLog.appendLog(Log.getStackTraceString(e));
    }
    return lVideoUrl;
}
 
开发者ID:SalmanTKhan,项目名称:MyAnimeViewer,代码行数:38,代码来源:Parser.java

示例12: getEpisodeVideo

import org.jsoup.select.Elements; //导入方法依赖的package包/类
@Override
public String getEpisodeVideo(String url) {
    String lVideoUrl = "";
    try {
        Document docdata = Jsoup.connect(url).userAgent(getUserAgent())
                .referrer(getServerUrl())
                .timeout(Parser.getParseTimeOut()).get();
        Element scriptElement = docdata.select("head").select("script").last();
        Elements downloadEle = docdata.select("li[class=bg-download]").select("a");
        if (downloadEle != null && !downloadEle.isEmpty()) {
            String downloadLink = downloadEle.get(0).attr("href");
            if (!TextUtils.isEmpty(downloadLink)) {
                lVideoUrl = getInternalVideoUrlAniUploader(downloadLink);
            }
        } else {
            String temp = "";
            String tempArray[];
            String tempVideoUrl = "";
            if (scriptElement != null) {
                temp = scriptElement.data();
                if (!TextUtils.isEmpty(temp)) {
                    tempArray = temp.split("\n");
                    for (String text : tempArray) {
                        if (text.contains("var stream")) {
                            lVideoUrl = text.substring(text.indexOf("\"") + 1, text.lastIndexOf("\""));
                        }
                    }
                }
            }
            if (lVideoUrl.contains("cdn-stream")) {
                lVideoUrl = getInternalVideoUrl(lVideoUrl);
            }
        }
    } catch (IOException e) {
        WriteLog.appendLog(Log.getStackTraceString(e));
    }
    return lVideoUrl;
}
 
开发者ID:SalmanTKhan,项目名称:MyAnimeViewer,代码行数:39,代码来源:AnimeTv.java

示例13: moveWarningToLessonNode

import org.jsoup.select.Elements; //导入方法依赖的package包/类
private void moveWarningToLessonNode(Elements e) {
    Elements warn = e.select(".uwaga-panel");

    if (!warn.isEmpty()) {
        e.select(".x-treelabel-rlz").last().text("(" + warn.text() + ")");
        e.remove(1);
    }
}
 
开发者ID:wulkanowy,项目名称:wulkanowy,代码行数:9,代码来源:Timetable.java

示例14: run

import org.jsoup.select.Elements; //导入方法依赖的package包/类
@Override
public void run() {
    Document doc;

    try {
        doc = get(mUrl);
    } catch (IOException e) {
        e.printStackTrace();
        failedOnUI(e.getMessage());
        return;
    }

    Elements topicDetailElements = doc.select("div.topic-detail");

    if (topicDetailElements.isEmpty()) {
        failedOnUI("找不到主题详情");
        return;
    }

    Elements elements = topicDetailElements.select("div.ui-header");

    if (elements.isEmpty()) {
        failedOnUI("找不到主题元信息");
        return;
    }

    TopicDetail topicDetail = new TopicDetail();

    Topic topic = GetTopicListTask.createTopicFromElement(elements.first());

    topicDetail.setTopic(topic);
    // 解析收藏
    Elements favouriteElement = doc.select(".J_topicFavorite");
    if(favouriteElement!=null){
        String hrefUrl = favouriteElement.attr("href");
        String dataType = favouriteElement.attr("data-type");
        String text = favouriteElement.text();
        Favorite favorite = new Favorite();
        favorite.setUrl(hrefUrl);
        favorite.setDataType(dataType);
        favorite.setText(text);
        topicDetail.setFavorite(favorite);
    }

    elements = topicDetailElements.select("div.ui-content");

    if (elements.isEmpty()) {
        failedOnUI("找不到主题内容");
        return;
    }

    topicDetail.setContent(elements.first().outerHtml());

    Elements commentsElements = doc.select("div.topic-reply");

    Map<Integer, Comment> comments = GetCommentsTask.getCommentsFromElements(commentsElements);

    topicDetail.setComments(comments);

    successOnUI(topicDetail);
}
 
开发者ID:mzlogin,项目名称:guanggoo-android,代码行数:62,代码来源:GetTopicDetailTask.java

示例15: run

import org.jsoup.select.Elements; //导入方法依赖的package包/类
@Override
public void run() {
    List<Reply> replies = new ArrayList<>();

    boolean succeed = false;
    boolean hasMore = false;

    try {
        Document doc = get(mUrl);

        Elements elements = doc.select("div.reply-item");

        for (Element element : elements) {
            Reply reply = new Reply();

            Elements topicElements = element.select("span.title a");
            if (topicElements.isEmpty()) {
                continue;
            }

            Topic topic = new Topic();
            topic.setTitle(topicElements.first().text());
            topic.setUrl(topicElements.first().absUrl("href"));

            reply.setTopic(topic);

            Elements contentElements = element.select("div.content");
            if (contentElements.isEmpty()) {
                continue;
            }

            reply.setContent(contentElements.outerHtml());

            replies.add(reply);
        }

        succeed = true;

        Elements paginationElements = doc.select("ul.pagination");
        if (!paginationElements.isEmpty()) {
            Elements disabledElements = paginationElements.select("li.disabled");
            if (disabledElements.isEmpty()) {
                hasMore = true;
            } else if (disabledElements.last() != null) {
                Elements disableLinkElements = disabledElements.last().select("a");
                if (!ConstantUtil.NEXT_PAGE.equals(disableLinkElements.text())) {
                    hasMore = true;
                }
            }
        }
    } catch (IOException e) {
        e.printStackTrace();
    }

    if (succeed) {
        ReplyList replyList = new ReplyList();
        replyList.setReplies(replies);
        replyList.setHasMore(hasMore);
        successOnUI(replyList);
    } else {
        failedOnUI("获取回复列表失败");
    }
}
 
开发者ID:mzlogin,项目名称:guanggoo-android,代码行数:64,代码来源:GetReplyListTask.java


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