Пример #1
0
  @Override
  protected List<Image> getImagesToAlbum(Album album) {

    setImagesList(new ArrayList<Image>());
    setDocument(ParserManagement.getDocument(album.getUrl()));

    if (notNull(getDocument())) {
      Elements imagesElements =
          getDocument().select("[data-role=content]").get(0).select("img[src]");

      if (notNull(imagesElements)) {
        for (Element imageElement : imagesElements) {

          String imageUrl = imageElement.attr("src");
          if (!imageUrl.endsWith(".jpg")) {
            imageUrl = imageElement.attr("data-lazyload-src");
          }

          String width = imageElement.attr("width");
          String height = imageElement.attr("height");
          String alt = imageElement.attr("alt");

          if (notNullAndNotIsEmpty(imageUrl) && imageUrl.endsWith(".jpg")) {
            getImagesList()
                .add(new Image(imageUrl, getAuthor(), width, height, alt, getPortfolio(), album));
          }
        }
      }
    }

    return getImagesList();
  }
Пример #2
0
  @Override
  public Portfolio parsing() {
    Elements albumsElements = getDocument().select("div.text-below").select("a[href]");
    if (notNull(albumsElements)) {
      for (Element albumElement : albumsElements) {
        String albumUrl = albumElement.attr("href");
        String title = albumElement.text();

        if (notNullAndNotIsEmpty(albumUrl, title)) {
          Album album = new Album(albumUrl, getAuthor(), title, getPortfolio());
          album.setImages(getImagesToAlbum(album));
          getAlbumsList().add(album);
        }
      }
    }

    getPortfolio().setAlbums(getAlbumsList());
    return getPortfolio();
  }