當前位置: 首頁>>代碼示例>>Java>>正文


Java Element.attr方法代碼示例

本文整理匯總了Java中org.jsoup.nodes.Element.attr方法的典型用法代碼示例。如果您正苦於以下問題:Java Element.attr方法的具體用法?Java Element.attr怎麽用?Java Element.attr使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.jsoup.nodes.Element的用法示例。


在下文中一共展示了Element.attr方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getURLsFromPage

import org.jsoup.nodes.Element; //導入方法依賴的package包/類
@Override
public List<String> getURLsFromPage(Document doc) {
    List<String> URLs = new ArrayList<>();
    //Pictures
    Elements imgs = doc.select("div.img > img.img-front");
    for (Element img : imgs) {
        String imageURL = img.attr("src");
        imageURL = "https:" + imageURL;
        URLs.add(imageURL);
    }
    //Videos
    Elements vids = doc.select("div.video > video > source");
    for (Element vid : vids) {
        String videoURL = vid.attr("src");
        URLs.add("https:" + videoURL);
    }

    return URLs;
}
 
開發者ID:RipMeApp,項目名稱:ripme,代碼行數:20,代碼來源:EromeRipper.java

示例2: getAlbumTitle

import org.jsoup.nodes.Element; //導入方法依賴的package包/類
@Override
public String getAlbumTitle(URL url) throws MalformedURLException {
    if (!is_profile(url)) {
        try {
            // Attempt to use album title as GID
            Element titleElement = getFirstPage().select("meta[property=og:title]").first();
            String title = titleElement.attr("content");
            title = title.substring(title.lastIndexOf('/') + 1);
            return getHost() + "_" + getGID(url) + "_" + title.trim();
        } catch (IOException e) {
            // Fall back to default album naming convention
            logger.info("Unable to find title at " + url);
        }
        return super.getAlbumTitle(url);
    }
    return url.toExternalForm().split("/u/")[1];
}
 
開發者ID:RipMeApp,項目名稱:ripme,代碼行數:18,代碼來源:EroShareRipper.java

示例3: getStringResNameAndValueMap

import org.jsoup.nodes.Element; //導入方法依賴的package包/類
/**
 * 獲取strings.xml 資源名-值 映射表
 *
 * @return
 */
protected Map<String, String> getStringResNameAndValueMap() {
    Map<String, String> map = new HashMap<>();

    Document document = getValuesXmlDocument();
    Elements strings  = document.getElementsByTag("string");

    for (int i = 0; i < strings.size(); i++) {
        Element element = strings.get(i);
        String  name    = element.attr("name");

        if (element.childNodeSize() > 0 && element.childNode(0) instanceof TextNode) {
            String text = ((TextNode) element.childNode(0)).text();

            map.put(name, text);
        }
    }

    return map;
}
 
開發者ID:kkmike999,項目名稱:YuiHatano,代碼行數:25,代碼來源:ShadowResources.java

示例4: getSnpPageUrl

import org.jsoup.nodes.Element; //導入方法依賴的package包/類
public String getSnpPageUrl() throws IOException, NotLoggedInErrorException {
    if (null != getId()) {
        return getBaseUrl();
    }

    // get url to uonetplus-opiekun.vulcan.net.pl
    Document startPage = getPageByUrl(getStartPageUrl());
    Element studentTileLink = startPage.select(".panel.linkownia.pracownik.klient > a").first();

    if (null == studentTileLink) {
        throw new NotLoggedInErrorException();
    }

    String snpPageUrl = studentTileLink.attr("href");

    this.id = getExtractedIdFromUrl(snpPageUrl);

    return snpPageUrl;
}
 
開發者ID:wulkanowy,項目名稱:wulkanowy,代碼行數:20,代碼來源:StudentAndParent.java

示例5: initAdd

import org.jsoup.nodes.Element; //導入方法依賴的package包/類
/**
 * 獲取最新入庫小說
 */
private void initAdd(List<FictionModel> list) {

    FictionModel pushTitle = new FictionModel();
    pushTitle.title = TYPE_TITLE_ADD;
    pushTitle.type = TYPE_TITLE;
    list.add(pushTitle);

    FictionModel kswListModel;
    Elements select = document.select("div.r").select("a[href]");
    for (Element element : select) {
        kswListModel = new FictionModel();
        kswListModel.title = element.text();
        kswListModel.detailUrl = element.attr("abs:href");
        kswListModel.type = TYPE_ADD;
        list.add(kswListModel);
    }
}
 
開發者ID:7449,項目名稱:JsoupSample,代碼行數:21,代碼來源:JsoupFictionListManager.java

示例6: savePandaLivesToRedis

import org.jsoup.nodes.Element; //導入方法依賴的package包/類
private void savePandaLivesToRedis(Document document) {
    List<Video> lives = new ArrayList<>();
    Elements elements = document.select("li.video-list-item.video-no-tag");
    for (Element element : elements) {
        Video videoDTO = new Video();
        String title = element.select("div.video-info span.video-nickname").text();
        String image = element.select("img.video-img").attr("data-original");
        image = image.replace("http:", "");
        String url = PANDA + element.attr("data-id");
        videoDTO.setTitle(title);
        videoDTO.setImage(image);
        videoDTO.setValue(url);
        lives.add(videoDTO);
        if (lives.size() > 48) {
            break;
        }
    }
    String key = redisSourceManager.VIDEO_PREFIx_HOME_LIVE_KEY + "_" + TAG;
    redisSourceManager.saveVideos(key, lives);
}
 
開發者ID:BENULL,項目名稱:LushX,代碼行數:21,代碼來源:PandaCrawler.java

示例7: initPush

import org.jsoup.nodes.Element; //導入方法依賴的package包/類
/**
 * 獲取熱門小說
 */
private void initPush(List<FictionModel> list) {
    FictionModel kswModel;
    Elements select = document.select("div.r").eq(0).select("a[href]");

    FictionModel hotTitle = new FictionModel();
    hotTitle.title = TYPE_TITLE_HOT;
    hotTitle.type = TYPE_TITLE;
    list.add(hotTitle);

    for (Element element : select) {
        kswModel = new FictionModel();
        kswModel.title = element.text();
        kswModel.detailUrl = element.attr("abs:href");
        kswModel.type = TYPE_HOT;
        list.add(kswModel);
    }

    initCenterHeader(list);
}
 
開發者ID:7449,項目名稱:JsoupSample,代碼行數:23,代碼來源:JsoupFictionHomeManager.java

示例8: getNextPage

import org.jsoup.nodes.Element; //導入方法依賴的package包/類
@Override
public Document getNextPage(Document doc) throws IOException {
    // Find next page
    String nextUrl = "";
    Element elem = doc.select("div.bg-white > ul.pagination > li > a").last();
    if (elem == null) {
        throw new IOException("No more pages");
    }
    nextUrl = elem.attr("href");
    // We use the global lastPage to check if we've already ripped this page
    // and is so we quit as there are no more pages
    if (nextUrl.equals(lastPage)) {
        throw new IOException("No more pages");
    }
    lastPage = nextUrl;
    // Sleep for half a sec to avoid getting IP banned
    sleep(500);
    return Http.url(nextUrl).get();
}
 
開發者ID:RipMeApp,項目名稱:ripme,代碼行數:20,代碼來源:Hentai2readRipper.java

示例9: 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

示例10: 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

示例11: rip

import org.jsoup.nodes.Element; //導入方法依賴的package包/類
@Override
public void rip() throws IOException {
    logger.info("Retrieving " + this.url);
    Document doc = Http.url(url).get();
    Element iframe = doc.select("iframe").first();
    String iframeSrc = iframe.attr("src");
    if (iframeSrc != null) {
        doc = Http.url("http://www.yuvutu.com" + iframeSrc).get();
    } else {
        throw new IOException("Could not find iframe code at " + url);
    }
    Elements script = doc.select("script");
    if (script.size() == 0) {
        throw new IOException("Could not find script code at " + url);
    }
    Pattern p = Pattern.compile("file: \"(.*?)\"");
    
    for (Element element : script) {
        Matcher m = p.matcher(element.data());
        if (m.find()){
            String vidUrl = m.group(1);
            addURLToDownload(new URL(vidUrl), HOST + "_" + getGID(this.url));
        }
    }
    waitForThreads();
}
 
開發者ID:RipMeApp,項目名稱:ripme,代碼行數:27,代碼來源:YuvutuRipper.java

示例12: linkTraversal

import org.jsoup.nodes.Element; //導入方法依賴的package包/類
private void linkTraversal(Elements links) throws IOException {
    // Iterate through links
    for(Element link: links) {
        String absoluteLink = link.attr("abs:href");
        String solution = java.net.URLDecoder.decode(absoluteLink, "UTF-8");   // Convert link to absolute link and decode it with url decoder
        String fileName = solution.substring(solution.indexOf("challenges/") + "challanges/".length(), solution.indexOf("?"));   // Extract file name from url
        solution = solution.substring(solution.indexOf("\n"));    // after the first new line, rest of the link is the solution
        Document solutionPage = getInstructionDocument(absoluteLink);
        String instructionString = getInstructions(solutionPage);  // get the instructions as a string
        callWriter(fileName, instructionString, solution);
    }
}
 
開發者ID:yavuzovski,項目名稱:freecodecamp-scraper,代碼行數:13,代碼來源:Scraper.java

示例13: getId

import org.jsoup.nodes.Element; //導入方法依賴的package包/類
@Nonnull
@Override
public String getId() throws ParsingException {
    try {
        Element element = doc.getElementsByClass("yt-uix-subscription-button").first();
        if (element == null) element = doc.getElementsByClass("yt-uix-subscription-preferences-button").first();

        return element.attr("data-channel-external-id");
    } catch (Exception e) {
        throw new ParsingException("Could not get channel id", e);
    }
}
 
開發者ID:TeamNewPipe,項目名稱:NewPipeExtractor,代碼行數:13,代碼來源:YoutubeChannelExtractor.java

示例14: getUrl

import org.jsoup.nodes.Element; //導入方法依賴的package包/類
@Override
public String getUrl() throws ParsingException {
    try {
        Element el = item.select("div[class*=\"yt-lockup-video\"").first();
        Element dl = el.select("h3").first().select("a").first();
        return dl.attr("abs:href");
    } catch (Exception e) {
        throw new ParsingException("Could not get web page url for the video", e);
    }
}
 
開發者ID:TeamNewPipe,項目名稱:NewPipeExtractor,代碼行數:11,代碼來源:YoutubeStreamInfoItemExtractor.java

示例15: getNextPage

import org.jsoup.nodes.Element; //導入方法依賴的package包/類
@Override
public Document getNextPage(Document doc) throws IOException {
    // Find next page
    String nextUrl = "";
    Element elem = doc.select("a.pg_next").first();
        nextUrl = elem.attr("href");
        if (nextUrl.equals("") || nextUrl.equals("#")) {
            throw new IOException("No more pages");
        }
        return Http.url(nextUrl).get();
    }
 
開發者ID:RipMeApp,項目名稱:ripme,代碼行數:12,代碼來源:WebtoonsRipper.java


注:本文中的org.jsoup.nodes.Element.attr方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。