本文整理匯總了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;
}