本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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 "";
}
}
示例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();
}
示例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 "";
}
}
示例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();
}
示例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 "";
}
}
示例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);
}
示例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);
}
}
}
}
}
}
示例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;
}
示例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;
}
示例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);
}
}
示例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);
}
示例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("获取回复列表失败");
}
}