本文整理汇总了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;
}