本文整理汇总了Java中org.jsoup.nodes.Element.getElementsByClass方法的典型用法代码示例。如果您正苦于以下问题:Java Element.getElementsByClass方法的具体用法?Java Element.getElementsByClass怎么用?Java Element.getElementsByClass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jsoup.nodes.Element
的用法示例。
在下文中一共展示了Element.getElementsByClass方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: meiyuxsCatalog
import org.jsoup.nodes.Element; //导入方法依赖的package包/类
private static Map meiyuxsCatalog(Map map, String url) {
try {
List data = new ArrayList();
Document document = Jsoup
.connect(url)
.userAgent(FormatUtil.USER_AGENT_PC)
.get();
Element body = document.body();
Elements catalogEles = body.getElementsByClass("list-group-item");
for (Element catalogE : catalogEles) {
if (catalogE.getElementsByTag("a").size() > 0) {
Map<String, Object> _map = new HashMap<>();
_map.put("catalog", catalogE.text());
_map.put("href", "http://www.meiyuxs.com" + catalogE.getElementsByTag("a").first().attr("href"));
data.add(_map);
}
}
map.put("data", data);
map.put("cover", "");
map.put("lastChapter", ((Map) data.get(data.size() - 1)).get("catalog").toString());
} catch (IOException e) {
e.printStackTrace();
}
return map;
}
示例2: getJoinTimeInDays
import org.jsoup.nodes.Element; //导入方法依赖的package包/类
@Override
public int getJoinTimeInDays() throws Exception {
Element rootNode = document.getElementsByClass("profile-stats-container").first();
Elements stats = rootNode.getElementsByClass("profile-stat");
for (Element stat : stats) {
String name = stat.getElementsByClass("text-label").first().text();
if (name.equalsIgnoreCase("Join Date")) {
String date = stat.getElementsByClass("text-lead").first().text();
SimpleDateFormat format = new SimpleDateFormat("MM/dd/yyyy");
Date currentDate = new Date();
Date newDate = format.parse(date);
long diff = currentDate.getTime() - newDate.getTime();
return Math.toIntExact(TimeUnit.DAYS.convert(diff, TimeUnit.MILLISECONDS));
}
}
return 0;
}
示例3: getThumbnailURLs
import org.jsoup.nodes.Element; //导入方法依赖的package包/类
@Override
public List<String> getThumbnailURLs() throws Exception {
String url = "https://www.roblox.com/games/" + id + "/none";
Document document = Jsoup.connect(url).ignoreContentType(true).get();
List<String> thumbnailLinks = new ArrayList<>();
Element root = document.getElementsByClass("carousel-inner").first();
Elements items = root.getElementsByClass("item");
for (Element item : items) {
Element imgTag = item.getElementsByTag("img").first();
thumbnailLinks.add(imgTag.attr("src"));
}
return thumbnailLinks;
}
示例4: getForumPostAmount
import org.jsoup.nodes.Element; //导入方法依赖的package包/类
@Override
public int getForumPostAmount() throws Exception {
Element rootNode = document.getElementsByClass("profile-stats-container").first();
Elements stats = rootNode.getElementsByClass("profile-stat");
for (Element stat : stats) {
String name = stat.getElementsByClass("text-label").first().text();
if (name.equalsIgnoreCase("Forum Posts")) {
String lead = stat.getElementsByClass("text-lead").first().text();
return Integer.parseInt(lead.replace(",", ""));
}
}
return 0;
}