当前位置: 首页>>代码示例>>Java>>正文


Java Element.hasAttr方法代码示例

本文整理汇总了Java中org.jsoup.nodes.Element.hasAttr方法的典型用法代码示例。如果您正苦于以下问题:Java Element.hasAttr方法的具体用法?Java Element.hasAttr怎么用?Java Element.hasAttr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jsoup.nodes.Element的用法示例。


在下文中一共展示了Element.hasAttr方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getURLsFromPage

import org.jsoup.nodes.Element; //导入方法依赖的package包/类
@Override
public List<String> getURLsFromPage(Document doc) {
    List<String> imageURLs = new ArrayList<>();
    for (Element thumb : doc.select("#gallery img")) {
        if (!thumb.hasAttr("src") || !thumb.hasAttr("width")) {
            continue;
        }
        String image = thumb.attr("src");
        image = image.replaceAll(
                "http://x.*.fap.to/images/thumb/",
                "http://fap.to/images/full/");
        image = image.replaceAll("w[0-9]+-h[0-9]+/", "");
        imageURLs.add(image);
        if (isThisATest()) {
            break;
        }
    }
    return imageURLs;
}
 
开发者ID:RipMeApp,项目名称:ripme,代码行数:20,代码来源:ImagefapRipper.java

示例2: ripUserAccount

import org.jsoup.nodes.Element; //导入方法依赖的package包/类
/**
 * Rips all albums in an imgur user's account.
 * @param url
 *      URL to imgur user account (http://username.imgur.com)
 * @throws IOException
 */
private void ripUserAccount(URL url) throws IOException {
    logger.info("Retrieving " + url);
    sendUpdate(STATUS.LOADING_RESOURCE, url.toExternalForm());
    Document doc = Http.url(url).get();
    for (Element album : doc.select("div.cover a")) {
        stopCheck();
        if (!album.hasAttr("href")
                || !album.attr("href").contains("imgur.com/a/")) {
            continue;
        }
        String albumID = album.attr("href").substring(album.attr("href").lastIndexOf('/') + 1);
        URL albumURL = new URL("http:" + album.attr("href") + "/noscript");
        try {
            ripAlbum(albumURL, albumID);
            Thread.sleep(SLEEP_BETWEEN_ALBUMS * 1000);
        } catch (Exception e) {
            logger.error("Error while ripping album: " + e.getMessage(), e);
        }
    }
}
 
开发者ID:RipMeApp,项目名称:ripme,代码行数:27,代码来源:ImgurRipper.java

示例3: getURLsFromPage

import org.jsoup.nodes.Element; //导入方法依赖的package包/类
@Override
public List<String> getURLsFromPage(Document page) {
    List<String> imageURLs = new ArrayList<>();
    // Page contains images
    logger.info("Look for images.");
    for (Element thumb : page.select("img")) {
        logger.info("Img");
        if (super.isStopped()) break;
        // Find thumbnail image source
        String image = null;
        String img_type = null;
        String src = null;
        if (thumb.hasAttr("typeof")) {
            img_type = thumb.attr("typeof");
            if (img_type.equals("foaf:Image")) {
              logger.debug("Found image with " + img_type);
              if (thumb.parent() != null &&
                  thumb.parent().parent() != null &&
                  thumb.parent().parent().attr("class") != null &&
                  thumb.parent().parent().attr("class").equals("aimage-center")
                 )
              {
                 src = thumb.attr("src");
                 logger.debug("Found url with " + src);
                 if (!src.contains("zizki.com")) {
                 } else {
                   imageURLs.add(src.replace("/styles/medium/public/","/styles/large/public/"));
                 }
               }
            }
        }
    }
    return imageURLs;
}
 
开发者ID:RipMeApp,项目名称:ripme,代码行数:35,代码来源:ZizkiRipper.java

示例4: replace

import org.jsoup.nodes.Element; //导入方法依赖的package包/类
private static void replace(Elements elements, String attrName) {
    String cdnDomain = Jboot.config(JbootRenderConfig.class).getCdn();
    Iterator<Element> iterator = elements.iterator();
    while (iterator.hasNext()) {

        Element element = iterator.next();

        if (element.hasAttr("cdn-exclude")) {
            continue;
        }

        String url = element.attr(attrName);
        if (StringUtils.isBlank(url) || !url.startsWith("/") || url.startsWith("//")) {
            continue;
        }

        url = cdnDomain + url;

        element.attr(attrName, url);
    }
}
 
开发者ID:yangfuhai,项目名称:jboot,代码行数:22,代码来源:RenderHelpler.java

示例5: 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;
}
 
开发者ID:Augugrumi,项目名称:libris,代码行数:22,代码来源:URLGoogleImageSearcher.java

示例6: processMessageViews

import org.jsoup.nodes.Element; //导入方法依赖的package包/类
private void processMessageViews(URL url, String html)
{
    Document document = Jsoup.parse(html);
    Elements elements = document.select("user-container");

    for (Element e : elements)
    {
        Elements link = e.select("a");
        Element signature = new Element("");

        for (Element e1 : link)
        {
            if (e1.hasAttr("class") && e1.attr("class").equals("signature"))
            {
                signature = e1;
                break;
            }
        }

    }
}
 
开发者ID:HueToYou,项目名称:ChatExchange-old,代码行数:22,代码来源:ChatFragment.java

示例7: getInternalVideoUrl

import org.jsoup.nodes.Element; //导入方法依赖的package包/类
private String getInternalVideoUrl(String url) {
    WriteLog.appendLog("getInternalVideoUrl(" + url + ") called");
    String lVideoUrl = "";
    try {
        Document docdata = Jsoup.connect(url).userAgent(getUserAgent())
                .referrer(getServerUrl())
                .timeout(Parser.getParseTimeOut()).get();
        Elements scriptEles = docdata.select("div[class=videocontent]").select("video").select("source");
        Element script = null;
        String text = "";
        if (scriptEles != null) {
            for (int i = 0; i < scriptEles.size(); i++) {
                script = scriptEles.get(i);
                if (script != null && script.hasAttr("src"))
                    lVideoUrl = script.attr("src");
            }
        }
    } catch (IOException e) {
        WriteLog.appendLog(Log.getStackTraceString(e));
    }
    return lVideoUrl;
}
 
开发者ID:SalmanTKhan,项目名称:MyAnimeViewer,代码行数:23,代码来源:AnimeTv.java

示例8: getEstreamToVideo

import org.jsoup.nodes.Element; //导入方法依赖的package包/类
public String getEstreamToVideo(String url) {
    String lVideoUrl = "";
    try {
        Document docdata = Jsoup.connect(url).userAgent(mUserAgent)
                .referrer("http://www.google.com")
                .timeout(Parser.getParseTimeOut()).get();
        Elements eles = null;
        if (!url.contains("embed")) {
            eles = docdata.select("div[class=leftcol]").select("iframe");
            if (eles != null && !eles.isEmpty()) {
                url = eles.get(0).attr("src");
                return getMP4UploadComVideo(url);
            }
        } else {
            eles = docdata.select("video").select("source");
            for (Element element : eles) {
                if (element.hasAttr("type") && element.attr("type").startsWith("video")) {
                    return element.attr("abs:src");
                }
            }
        }
    } catch (IOException e) {
        WriteLog.appendLog(Log.getStackTraceString(e));
    }
    return lVideoUrl;
}
 
开发者ID:SalmanTKhan,项目名称:MyAnimeViewer,代码行数:27,代码来源:Parser.java

示例9: getNextPage

import org.jsoup.nodes.Element; //导入方法依赖的package包/类
@Override
public Document getNextPage(Document doc) throws IOException {
    Element pagination = doc.select("div.pagination").first();
    if (pagination.hasAttr("next-page-url")) {
        String nextPage = pagination.attr("abs:next-page-url");
        // Only logged in users can see past page 25
        // Trying to rip page 26 will throw a no images found error
        if (!nextPage.contains("page=26")) {
            logger.info("Getting next page: " + pagination.attr("abs:next-page-url"));
            return Http.url(pagination.attr("abs:next-page-url")).cookies(cookies).get();
        }
    }
    throw new IOException("No more pages");
}
 
开发者ID:RipMeApp,项目名称:ripme,代码行数:15,代码来源:SankakuComplexRipper.java

示例10: rip

import org.jsoup.nodes.Element; //导入方法依赖的package包/类
@Override
public void rip() throws IOException {
    int index = 0;
    logger.info("Retrieving " + this.url);
    sendUpdate(STATUS.LOADING_RESOURCE, this.url.toExternalForm());
    if (albumDoc == null) {
        albumDoc = Http.url(url).get();
    }
    for (Element thumb : albumDoc.select("#galleryImages > a > img")) {
        if (!thumb.hasAttr("src")) {
            continue;
        }
        String image = thumb.attr("src");
        image = image.replace(
                "/thumbs/",
                "/");
        index += 1;
        String prefix = "";
        if (Utils.getConfigBoolean("download.save_order", true)) {
            prefix = String.format("%03d_", index);
        }
        addURLToDownload(new URL(image), prefix);
        if (isThisATest()) {
            break;
        }
    }
    waitForThreads();
}
 
开发者ID:RipMeApp,项目名称:ripme,代码行数:29,代码来源:TeenplanetRipper.java

示例11: getURLsFromPage

import org.jsoup.nodes.Element; //导入方法依赖的package包/类
@Override
public List<String> getURLsFromPage(Document page) {
    List<String> imageURLs = new ArrayList<>();
    Pattern p; Matcher m;
    //select all album thumbnails
    for (Element span : page.select(".NA_articleGallery span")) {
        if (!span.hasAttr("style")) {
            continue;
        }
        String style = span.attr("style").trim();

        p = Pattern.compile("background-image: url\\((.*list_thumb_inbox.*)\\);", Pattern.CASE_INSENSITIVE);
        m = p.matcher(style);
        if (m.find()) {
            String imgUrl = m.group(1);
            if (imgUrl.startsWith("//")) {
                imgUrl = "http:" + imgUrl;
            }
            if (imgUrl.startsWith("/")) {
                imgUrl = "http://" + this.url.getHost() + imgUrl;
            }
            //convert thumbnail url into fullsize url
            imgUrl = imgUrl.replace("list_thumb_inbox","xlarge");
            // Don't download the same URL twice
            if (imageURLs.contains(imgUrl)) {
                logger.debug("Already attempted: " + imgUrl);
                continue;
            }
            imageURLs.add(imgUrl);
            if (isThisATest()) {
                break;
            }
        }

        if (isStopped()) {
            break;
        }
    }
    return imageURLs;
}
 
开发者ID:RipMeApp,项目名称:ripme,代码行数:41,代码来源:NatalieMuRipper.java

示例12: removeUselessAttributes

import org.jsoup.nodes.Element; //导入方法依赖的package包/类
public static void removeUselessAttributes(Element element) {
    for (Element child : element.getAllElements()) {
        if (child.hasAttr("style"))
            child.removeAttr("style");
    }
}
 
开发者ID:TheAndroidMaster,项目名称:Blackboard,代码行数:7,代码来源:HtmlUtils.java

示例13: getInternalVideoUrlAniUploader

import org.jsoup.nodes.Element; //导入方法依赖的package包/类
private String getInternalVideoUrlAniUploader(String url) {
    WriteLog.appendLog("getInternalVideoUrlAniUploader(" + url + ") called");
    String lVideoUrl = "";
    try {
        Document docdata = Jsoup.connect(url).userAgent(getUserAgent())
                .referrer(getServerUrl())
                .timeout(Parser.getParseTimeOut()).get();
        Elements scriptEles = docdata.select("div[class=dowload]").select("a");
        Element script = null;
        String text = "";
        String providerUrl = "";
        if (scriptEles != null) {
            for (int i = 0; i < scriptEles.size(); i++) {
                script = scriptEles.get(i);
                if (script != null && script.hasAttr("href")) {
                    providerUrl = script.attr("href");
                    lVideoUrl = getVideoFromProvider(providerUrl);
                    if (!TextUtils.isEmpty(lVideoUrl))
                        break;
                }
            }
        }
    } catch (IOException e) {
        WriteLog.appendLog(Log.getStackTraceString(e));
    }
    return lVideoUrl;
}
 
开发者ID:SalmanTKhan,项目名称:MyAnimeViewer,代码行数:28,代码来源:GoGoAnime.java

示例14: readDesign

import org.jsoup.nodes.Element; //导入方法依赖的package包/类
@Override
public void readDesign(Element design, DesignContext designContext) {
    super.readDesign(design, designContext);

    Attributes attr = design.attributes();

    if (design.hasAttr("time-zone")) {
        setZoneId(ZoneId.of(DesignAttributeHandler.readAttribute("end-date", attr, String.class)));
    }

    if (design.hasAttr("time-format")) {
        setTimeFormat(TimeFormat.valueOf(
                "Format" + design.attr("time-format").toUpperCase()));
    }

    if (design.hasAttr("start-date")) {
        setStartDate(
                ZonedDateTime.ofInstant(DesignAttributeHandler.readAttribute("start-date", attr, Date.class)
                        .toInstant(), getZoneId()));
    }

    if (design.hasAttr("end-date")) {
        setEndDate(
                ZonedDateTime.ofInstant(DesignAttributeHandler.readAttribute("end-date", attr, Date.class)
                        .toInstant(), getZoneId()));
    }
}
 
开发者ID:blackbluegl,项目名称:calendar-component,代码行数:28,代码来源:Calendar.java

示例15: getSrc

import org.jsoup.nodes.Element; //导入方法依赖的package包/类
private String getSrc(Element img) {
    String src = "";
    if (img.hasAttr("src")) {
        src = img.attr("src");
    } else if (img.hasAttr("data-src")) {
        src = img.attr("data-src");
    } else if (img.hasAttr("data-lazy-src")) {
        src = img.attr("data-lazy-src");
    }
    return src;
}
 
开发者ID:shekhargulati,项目名称:image-resolver,代码行数:12,代码来源:WebpageImageResolver.java


注:本文中的org.jsoup.nodes.Element.hasAttr方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。