本文整理汇总了Java中org.jsoup.nodes.Element.hasClass方法的典型用法代码示例。如果您正苦于以下问题:Java Element.hasClass方法的具体用法?Java Element.hasClass怎么用?Java Element.hasClass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jsoup.nodes.Element
的用法示例。
在下文中一共展示了Element.hasClass方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: retrieveLinksFromHTML
import org.jsoup.nodes.Element; //导入方法依赖的package包/类
private ArrayList<String> retrieveLinksFromHTML(Elements body) {
ArrayList<String> linkRes = new ArrayList<String>();
Elements links = body.select("div.g");
links = links.select("a[href]");
for (Element link : links){
if (!link.hasClass("_Fmb ab_button") &&
! link.hasClass("fl") &&
! link.hasClass("bia") &&
! link.hasClass("duf3") &&
! link.hasClass("iu-card-header") &&
! link.hasAttr("data-rtid") &&
! link.hasAttr("data-ved")) {
String toCheck = link.attr("href");
if (!linkRes.contains(toCheck)) {
linkRes.add(toCheck);
}
}
}
return linkRes;
}
示例2: call
import org.jsoup.nodes.Element; //导入方法依赖的package包/类
@Override
public Object call(Element element, List<SyntaxNode> params) {
Preconditions.checkArgument(params.size() > 0, "hasClass must have a parameter");
Object calc = params.get(0).calc(element);
if (!(calc instanceof String)) {
throw new EvaluateException("hasClass params must a String ,now is " + calc);
}
return element.hasClass(calc.toString().trim());
}
示例3: getURLs
import org.jsoup.nodes.Element; //导入方法依赖的package包/类
public static List<URL> getURLs(URL url) throws IOException{
Response resp = Http.url(url)
.ignoreContentType()
.response();
Document doc = resp.parse();
List<URL> URLs = new ArrayList<>();
//Pictures
Elements imgs = doc.getElementsByTag("img");
for (Element img : imgs) {
if (img.hasClass("album-image")) {
String imageURL = img.attr("src");
imageURL = "https:" + imageURL;
URLs.add(new URL(imageURL));
}
}
//Videos
Elements vids = doc.getElementsByTag("video");
for (Element vid : vids) {
if (vid.hasClass("album-video")) {
Elements source = vid.getElementsByTag("source");
String videoURL = source.first().attr("src");
URLs.add(new URL("https:" + videoURL));
}
}
return URLs;
}
示例4: getURLs
import org.jsoup.nodes.Element; //导入方法依赖的package包/类
public static List<URL> getURLs(URL url) throws IOException{
Response resp = Http.url(url)
.ignoreContentType()
.response();
Document doc = resp.parse();
List<URL> URLs = new ArrayList<>();
//Pictures
Elements imgs = doc.getElementsByTag("img");
for (Element img : imgs) {
if (img.hasClass("album-image")) {
String imageURL = img.attr("src");
imageURL = "https:" + imageURL;
URLs.add(new URL(imageURL));
}
}
//Videos
Elements vids = doc.getElementsByTag("video");
for (Element vid : vids) {
if (vid.hasClass("album-video")) {
Elements source = vid.getElementsByTag("source");
String videoURL = source.first().attr("src");
URLs.add(new URL(videoURL));
}
}
return URLs;
}
示例5: gatherDuyins
import org.jsoup.nodes.Element; //导入方法依赖的package包/类
private List<DuYinDM> gatherDuyins(Element contentEL)throws Exception{
Elements elements=contentEL.select("p");
DuYinDM dm=null;
List<DuYinDM> results=new ArrayList<DuYinDM>(3);
for (Element p : elements) {
if(p.children().isEmpty())continue;
Element firstChild=p.child(0);
if("span".equals(firstChild.tagName())){
if(firstChild.hasClass("dicpy")){
if(dm!=null){
results.add(dm);
}
dm=new DuYinDM();
String duyin=firstChild.text();
dm.setDuyin(duyin);
}
}else if("em".equals(firstChild.tagName())){
StringBuilder ziyi=new StringBuilder();
Node next=firstChild.nextSibling();
while(next!=null){
if(next instanceof TextNode){
ziyi.append(((TextNode) next).text());
}else if(next instanceof Element){
ziyi.append(((Element) next).text());
}
next=next.nextSibling();
}
dm.addZiyi(ziyi.toString());
}
}
if(dm!=null){
results.add(dm);
}
return results;
}
示例6: parseElement
import org.jsoup.nodes.Element; //导入方法依赖的package包/类
private MaterialData parseElement(Element element) {
MaterialData data = new MaterialData();
data.setId(element.select("div.columna1").text());
data.setSubjectId(element.attr("data-codasi"));
if (element.hasClass("carpeta")) {
data.setFolder(true);
if (!element.hasClass("filacarpvacia")) {
data.setAvailableFolder(true);
}
} else {
data.setType(element.select("div.columna2").text());
String typeName = element.select("div.columna4 > span.imagentipo > span.glyphs").attr("title");
data.setTypeName(typeName);
}
Element name = element.select("div.columna5aux").first();
if (name != null) {
data.setFileName(name.text());
} else {
data.setFileName(element.select("div.columna5").text());
}
data.setFileDescription(element.select("div.columna6").text());
data.setSubjectName(element.select("div.columna15").text());
data.setDate(element.select("div.columna13").text());
//Apartado Publisher
Element publisher = element.select("div.columna12 > span.publicador > img.imgcreador").first();
data.setPublisherName(publisher.attr("title"));
data.setPublisherPicture(publisher.attr("src"));
return data;
}