本文整理匯總了Java中org.jsoup.select.Elements.last方法的典型用法代碼示例。如果您正苦於以下問題:Java Elements.last方法的具體用法?Java Elements.last怎麽用?Java Elements.last使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.jsoup.select.Elements
的用法示例。
在下文中一共展示了Elements.last方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: parseCollectionsRepositoryData
import org.jsoup.select.Elements; //導入方法依賴的package包/類
private Repository parseCollectionsRepositoryData(Element element) throws Exception{
String fullName = element.select("div > div > a").attr("href");
String owner = fullName.substring(1, fullName.lastIndexOf("/"));
String repoName = fullName.substring(fullName.lastIndexOf("/") + 1);
String ownerAvatar = element.select("div > div > a > img").attr("src");
Elements articleElements = element.getElementsByTag("div");
Element descElement = articleElements.get(articleElements.size() - 2);
StringBuilder desc = new StringBuilder("");
for(TextNode textNode : descElement.textNodes()){
desc.append(textNode.getWholeText());
}
Element numElement = articleElements.last();
String starNumStr = numElement.select("a").get(0).textNodes().get(1).toString();
String forkNumStr = numElement.select("a").get(1).textNodes().get(1).toString();
String language = "";
Elements languageElements = numElement.select("span > span");
if(languageElements.size() > 0){
language = numElement.select("span > span").get(1).textNodes().get(0).toString();
}
Repository repo = new Repository();
repo.setFullName(fullName);
repo.setName(repoName);
User user = new User();
user.setLogin(owner);
user.setAvatarUrl(ownerAvatar);
repo.setOwner(user);
repo.setDescription(desc.toString());
repo.setStargazersCount(Integer.parseInt(starNumStr.replaceAll(" ", "")));
repo.setForksCount(Integer.parseInt(forkNumStr.replaceAll(" ", "")));
repo.setLanguage(language);
return repo;
}
示例2: doAnalysis
import org.jsoup.select.Elements; //導入方法依賴的package包/類
@Override
public List doAnalysis(String html) {
System.out.println(html);
Document doc = null;
doc = Jsoup.parse(html);
String cNameNo;
String cName;
String cEnglishName;
String credits;
String qualityHours;
String teachingHours;
String experimentalHours;
String computerClassHours;
String otherClassHours;
String teachingProgram;
String organization;
Elements elements = doc.select("table tbody tr td table tbody");
Element element = elements.last();
Elements childs = element.children().select("td");
cNameNo = childs.get(2).text();
if (cNameNo.trim().equals(""))
return null;
organization = childs.get(4).text();
cName = childs.get(6).text();
cEnglishName = childs.get(8).text();
credits = childs.get(10).text();
qualityHours = childs.get(12).text();
teachingHours = childs.get(14).text();
experimentalHours = childs.get(16).text();
computerClassHours = childs.get(18).text();
otherClassHours = childs.get(20).text();
teachingProgram = childs.get(26).select("div").text();
CoursePageBo coursePageBo = new CoursePageBo();
coursePageBo.setNameNo(cNameNo);
coursePageBo.setName(cName);
coursePageBo.setComputerClassHours(computerClassHours);
coursePageBo.setCredits(credits);
coursePageBo.setExperimentalHours(experimentalHours);
coursePageBo.setOrganization(organization);
coursePageBo.setOtherClassHours(otherClassHours);
coursePageBo.setQualityHours(qualityHours);
coursePageBo.setTeachingHours(teachingHours);
coursePageBo.setTeachingProgram(teachingProgram);
coursePageBo.setEnglishName(cEnglishName);
coursePageBo.setNo(getcNo());
List list = new LinkedList();
list.add(coursePageBo);
return list;
}
示例3: 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("獲取回複列表失敗");
}
}
示例4: run
import org.jsoup.select.Elements; //導入方法依賴的package包/類
@Override
public void run() {
List<Topic> topics = new ArrayList<>();
boolean succeed = false;
boolean hasMore = false;
try {
Document doc = get(mUrl);
Elements elements = doc.select("div.topic-item");
for (Element element : elements) {
Topic topic = createTopicFromElement(element);
topics.add(topic);
}
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) {
TopicList topicList = new TopicList();
topicList.setTopics(topics);
topicList.setHasMore(hasMore);
successOnUI(topicList);
} else {
failedOnUI("獲取主題列表失敗");
}
}
示例5: getEpisodeVideo
import org.jsoup.select.Elements; //導入方法依賴的package包/類
@Override
public String getEpisodeVideo(String url) {
String videoUrl = "";
try {
Document docdata = load(url, true);
Elements videoEle = docdata.select("div[class=play-video]").select("iframe");
if (videoEle != null && !videoEle.isEmpty()) {
String tempUrl = videoEle.attr("abs:src");
videoUrl = getVideoFromProvider(tempUrl);
if (!TextUtils.isEmpty(videoUrl))
return videoUrl;
}
Elements downloadEle = docdata.select("div[class=anime_video_body]")
.select("div[class=download-anime]").select("a");
if (downloadEle != null && !downloadEle.isEmpty()) {
String downloadLink = downloadEle.get(0).attr("href");
if (!TextUtils.isEmpty(downloadLink)) {
videoUrl = getInternalVideoUrlAniUploader(downloadLink);
if (!TextUtils.isEmpty(videoUrl)) {
return videoUrl;
}
}
} else {
Elements eles = docdata.select("div[id=video_container_div]").select("script");
if (eles != null && !eles.isEmpty()) {
Element playerScript = eles.last();
if (playerScript != null) {
String scriptText[] = playerScript.html().split("\n");
if (scriptText != null && scriptText.length > 0) {
for (int i = 0; i < scriptText.length; i++) {
if (scriptText[i].contains("file:")) {
videoUrl = scriptText[i].trim().replace("file: '", "").replace("',", "");
break;
}
}
}
}
//videoUrl = eles.select("video").select("source").attr("abs:src");
} else {
eles = docdata.select("iframe[class=mirrorVid]");
if (eles != null && !eles.isEmpty()) {
videoUrl = eles.attr("src");
if (!TextUtils.isEmpty(videoUrl))
videoUrl = getVideoFromProvider(videoUrl);
}
}
}
} catch (IOException e) {
WriteLog.appendLog(Log.getStackTraceString(e));
}
return videoUrl;
}
示例6: getEpisodeVideo
import org.jsoup.select.Elements; //導入方法依賴的package包/類
@Override
public String getEpisodeVideo(String url) {
String lVideoUrl = "";
try {
Document docdata = Jsoup.connect(url).userAgent(getUserAgent())
.referrer("http://www.google.com")
.timeout(Parser.getParseTimeOut()).get();
Elements eles = docdata.select("div[class=video-content]").select("iframe");
if (eles != null && !eles.isEmpty()) {
String videoUrlFromProvider = "";
for (Element ele : eles) {
lVideoUrl = ele.attr("src");
if (!TextUtils.isEmpty(lVideoUrl))
videoUrlFromProvider = getVideoFromProvider(lVideoUrl);
if (!TextUtils.isEmpty(videoUrlFromProvider)) {
lVideoUrl = videoUrlFromProvider;
break;
}
}
} else {
eles = docdata.select("div[id=videocontainer]").select("script");
if (eles != null && !eles.isEmpty()) {
Element playerScript = eles.last();
if (playerScript != null) {
String scriptText[] = playerScript.html().split("\n");
if (scriptText != null && scriptText.length > 0) {
for (int i = 0; i < scriptText.length; i++) {
if (scriptText[i].contains("file:")) {
lVideoUrl = scriptText[i].trim().replace("file: '", "").replace("',", "");
break;
}
}
}
}
}
//lVideoUrl = eles.select("video").select("source").attr("abs:src");
}
} catch (IOException e) {
WriteLog.appendLog(Log.getStackTraceString(e));
}
return lVideoUrl;
}