本文整理匯總了Java中org.jsoup.select.Elements.select方法的典型用法代碼示例。如果您正苦於以下問題:Java Elements.select方法的具體用法?Java Elements.select怎麽用?Java Elements.select使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.jsoup.select.Elements
的用法示例。
在下文中一共展示了Elements.select方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getContent
import org.jsoup.select.Elements; //導入方法依賴的package包/類
@Override
public Map<ContentsActivity.parameter, Object> getContent(String baseUrl, String currentUrl, byte[] result, Map<ContentsActivity.parameter, Object> resultMap) throws UnsupportedEncodingException {
List<AlbumInfo> urls = new ArrayList<>();
Document document = Jsoup.parse(new String(result, "gbk"));
Elements elements = document.select("#sliding li");
for (Element element : elements) {
AlbumInfo temp = new AlbumInfo();
Elements title = element.select(".p-title");
if (title.size() > 0)
temp.setTitle(title.get(0).text());
Elements album = element.select("a:has(img)");
temp.setAlbumUrl(baseUrl + album.attr("href"));
Elements pic = album.select("img");
if (pic.size() > 0)
temp.setPicUrl(pic.get(0).attr("src"));
urls.add(temp);
}
resultMap.put(ContentsActivity.parameter.CURRENT_URL, currentUrl);
resultMap.put(ContentsActivity.parameter.RESULT, urls);
return resultMap;
}
示例2: process
import org.jsoup.select.Elements; //導入方法依賴的package包/類
@Override
public Result process(Request request, Page page) {
Result result = new Result();
Elements elements = page.document().select("div.mainPanel table.table tr");
List<Map> list = new ArrayList<Map>();
for (Element element : elements) {
Elements tdElements = elements.select("td");
if (tdElements.size() > 5) {
Map<String, String> info = new HashMap<String, String>();
info.put("ip", tdElements.get(0).text());
info.put("port", tdElements.get(1).text());
info.put("country", tdElements.get(2).text());
info.put("anonymous", tdElements.get(3).text());
info.put("type", tdElements.get(4).text());
list.add(info);
}
}
result.put("list", list);
return result;
}
示例3: getSynonyms
import org.jsoup.select.Elements; //導入方法依賴的package包/類
public HashMap<String, ArrayList<String>> getSynonyms() throws IOException, InterruptedException {
if (synonyms.isEmpty()) {
for (String word : wordList) {
try {
Document doc = Jsoup.connect("http://www.thesaurus.com/browse/" + word)
.userAgent("Mozilla/5.0 (Windows NT 6.3; rv:36.0) Gecko/20100101 Firefox/36.0")
.timeout(3000)
.get();
Elements block = doc.getElementsByClass("relevancy-block");
Elements list = block.select(".relevancy-list");
Elements text = list.select(".text");
ArrayList<String> synonymList = new ArrayList<>();
for (int j = 0; j < text.size(); j++) {
synonymList.add(text.get(j).text());
}
synonyms.put(word, synonymList);
} catch (IOException e) {
}
}
}
return synonyms;
}
示例4: retrieveSimilarImageFromHTML
import org.jsoup.select.Elements; //導入方法依賴的package包/類
private ArrayList<String> retrieveSimilarImageFromHTML(Elements body) {
ArrayList<String> imageRes = new ArrayList<String>();
Elements images = body.select("div.rg_meta");
Gson gson = new Gson();
JsonObject jsImage;
String imageUrl;
for (Element image : images){
jsImage = gson.fromJson(image.text(), JsonObject.class);
imageUrl = jsImage.get("ou").getAsString();
try {
new URL(imageUrl);
imageRes.add(imageUrl);
} catch (MalformedURLException e) {
printMalformedError(e);
}
}
return imageRes;
}
示例5: getContent
import org.jsoup.select.Elements; //導入方法依賴的package包/類
@Override
public Map<ContentsActivity.parameter, Object> getContent(String baseUrl, String currentUrl, byte[] result, Map<ContentsActivity.parameter, Object> resultMap) throws UnsupportedEncodingException {
List<AlbumInfo> urls = new ArrayList<>();
Document document = Jsoup.parse(new String(result, "utf-8"));
Elements elements = document.select("div.album");
for (Element element : elements) {
AlbumInfo temp = new AlbumInfo();
Elements title = element.select("span.name");
if (title.size() > 0)
temp.setTitle(title.get(0).text());
Elements album = element.select(".pic_box a");
temp.setAlbumUrl(album.attr("href"));
Elements pic = album.select("img");
if (pic.size() > 0)
temp.setPicUrl(pic.get(0).attr("src"));
urls.add(temp);
}
resultMap.put(ContentsActivity.parameter.CURRENT_URL, currentUrl);
resultMap.put(ContentsActivity.parameter.RESULT, urls);
return resultMap;
}
示例6: getContent
import org.jsoup.select.Elements; //導入方法依賴的package包/類
@Override
public Map<ContentsActivity.parameter, Object> getContent(String baseUrl, String currentUrl, byte[] result, Map<ContentsActivity.parameter, Object> resultMap) throws UnsupportedEncodingException {
List<AlbumInfo> data = new ArrayList<>();
Document document = Jsoup.parse(new String(result, "utf-8"));
Elements elements = document.select("section");
for (Element element : elements) {
AlbumInfo temp = new AlbumInfo();
Elements album = element.select("a:has(img)");
if (album.size() > 0) {
temp.setAlbumUrl(album.attr("href"));
Elements pic = album.select("img");
if (pic.size() > 0)
temp.setPicUrl(pic.get(0).attr("data-src"));
}
data.add(temp);
}
resultMap.put(ContentsActivity.parameter.CURRENT_URL, currentUrl);
resultMap.put(ContentsActivity.parameter.RESULT, data);
return resultMap;
}
示例7: retrieveDescriptionFromHTML
import org.jsoup.select.Elements; //導入方法依賴的package包/類
private ArrayList<String> retrieveDescriptionFromHTML(Elements body) {
ArrayList<String> descRes = new ArrayList<String>();
Elements descriptions = body.select("span.st");
for (Element desc : descriptions)
descRes.add(desc.text());
return descRes;
}
示例8: 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 userProfileElements = doc.select("div.user-page .profile");
if (userProfileElements.isEmpty()) {
failedOnUI("獲取用戶資料失敗");
return;
}
Elements headerElements = userProfileElements.select("div.ui-header");
if (headerElements.isEmpty()) {
failedOnUI("獲取用戶資料失敗");
return;
}
UserProfile profile = new UserProfile();
profile.setUrl(mUrl);
profile.setAvatar(headerElements.select("img.avatar").attr("src"));
profile.setUsername(headerElements.select("div.username").text());
profile.setNumber(headerElements.select("div.user-number .number").text());
profile.setSince(headerElements.select("div.user-number .since").text());
if (profile.isValid()) {
successOnUI(profile);
} else {
failedOnUI("獲取用戶資料出錯");
}
}
示例9: getCommentsFromElements
import org.jsoup.select.Elements; //導入方法依賴的package包/類
public static Map<Integer, Comment> getCommentsFromElements(Elements elements) {
TreeMap<Integer, Comment> comments = new TreeMap<>();
Elements replyItems = elements.select("div.reply-item");
for (Element replyItem : replyItems) {
Comment comment = getCommentFromElement(replyItem);
comments.put(comment.getMeta().getFloor(), comment);
}
return comments.descendingMap();
}
示例10: setData
import org.jsoup.select.Elements; //導入方法依賴的package包/類
private void setData(List<FictionModel> list, int eq, String type) {
Elements select = document.select("div.blockcontent").eq(eq);
Elements itemElements = select.select("li");
list.add(getMoreTitle(type, select));
FictionModel fictionModel;
for (Element element : itemElements) {
fictionModel = new FictionModel();
Elements a = element.select("a");
fictionModel.title = a.text();
fictionModel.detailUrl = a.attr("abs:href");
fictionModel.type = TYPE_ITEM;
list.add(fictionModel);
}
}
示例11: readStepContent
import org.jsoup.select.Elements; //導入方法依賴的package包/類
private void readStepContent(Elements elements) {
Elements contentElements = elements.select(DESIGN_TAG_CONTENT);
if (!contentElements.isEmpty()) {
Element contentElement = contentElements.get(0);
Elements children = contentElement.children();
if (children.size() > 1) {
String msg = "Only one child allowed for tag <" + DESIGN_TAG_CONTENT + ">";
throw new IllegalArgumentException(msg);
}
Component component = designContext.readDesign(children.first());
setContent(component);
}
}
示例12: getContent
import org.jsoup.select.Elements; //導入方法依賴的package包/類
@Override
public Map<ContentsActivity.parameter, Object> getContent(String baseUrl, String currentUrl, byte[] result, Map<ContentsActivity.parameter, Object> resultMap) throws UnsupportedEncodingException {
List<AlbumInfo> urls = new ArrayList<>();
Document document = Jsoup.parse(new String(result, "gb2312"));
Elements elements = document.select(".piclist li");
for (Element element : elements) {
AlbumInfo temp = new AlbumInfo();
Elements title = element.select("a:has(img) span");
if (title.size() > 0)
temp.setTitle(title.get(0).text());
Elements time = element.select(".b1");
if (time.size() > 0)
temp.setTime(time.get(0).text());
Elements album = element.select("a:has(img)");
temp.setAlbumUrl(baseUrl + album.attr("href"));
Elements pic = album.select("img");
if (pic.size() > 0)
temp.setPicUrl(pic.get(0).attr("src"));
urls.add(temp);
}
resultMap.put(ContentsActivity.parameter.CURRENT_URL, currentUrl);
resultMap.put(ContentsActivity.parameter.RESULT, urls);
return resultMap;
}
示例13: retrieveTitleFromHTML
import org.jsoup.select.Elements; //導入方法依賴的package包/類
private ArrayList<String> retrieveTitleFromHTML(Elements body) {
ArrayList<String> titleRes = new ArrayList<String>();
Elements titles = body.select("h3.r");
for (Element title : titles)
titleRes.add(title.text());
return titleRes;
}
示例14: getContent
import org.jsoup.select.Elements; //導入方法依賴的package包/類
@Override
public Map<ContentsActivity.parameter, Object> getContent(String baseUrl, String currentUrl, byte[] result, Map<ContentsActivity.parameter, Object> resultMap) throws UnsupportedEncodingException {
List<AlbumInfo> data = new ArrayList<>();
Document document = Jsoup.parse(new String(result, "utf-8"));
Elements elements = document.select("section");
for (Element element : elements) {
AlbumInfo temp = new AlbumInfo();
Elements album = element.select(".card-bg > a:has(img)");
if (album.size() > 0) {
temp.setAlbumUrl(album.attr("href"));
Elements pic = album.select("img");
if (pic.size() > 0) {
Log.e("Acg12", "getContent: " + pic.get(0).attr("data-src"));
temp.setPicUrl(pic.get(0).attr("data-src"));
}
}
Elements title = element.select("h3.title");
if (title.size() > 0)
temp.setTitle(title.get(0).text());
Elements time = element.select("time");
if (time.size() > 0)
temp.setTime(time.attr("title") + " " + time.text());
data.add(temp);
}
resultMap.put(ContentsActivity.parameter.CURRENT_URL, currentUrl);
resultMap.put(ContentsActivity.parameter.RESULT, data);
return resultMap;
}
示例15: retrieveBestGuessFromHTML
import org.jsoup.select.Elements; //導入方法依賴的package包/類
private String retrieveBestGuessFromHTML(Elements body) {
String bestGuessRes;
Elements bestGuesses = body.select("a._gUb");
bestGuessRes = bestGuesses.first().text();
return bestGuessRes;
}