Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
adriens committed Apr 3, 2021
1 parent ef624c2 commit aacc715
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.github.adriens.imgflip</groupId>
<artifactId>imgflip4j</artifactId>
<version>1.3</version>
<version>1.4</version>
<packaging>jar</packaging>
<description>A Java SDK to interact with Imgflip API.</description>
<properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,15 @@ public static List<PublishedMeme> getPublishedMemes()

public static List<PublishedMeme> getPublishedMemes(int page)
throws IOException {
return getPublishedMemes(null, page);
return getPublishedMemes("fun", page);
}

public static List<PublishedMeme> getPublishedMemes(String stream, int page)
throws IOException {
String lStream;
if(stream == null || stream.isEmpty()){
lStream = "fun";
}
String imgFlipUrl = ImgFlipURLHelper.getPagePath(stream, page);
return getPublishedMemes(imgFlipUrl);
}
Expand All @@ -71,10 +75,10 @@ public static List<PublishedMeme> getPublishedMemes(String targetUrl)
Iterator<DomElement> memeDivsIterator = divMemesList.iterator();
int i = 1;
DomElement lDivision;
String imgPath;
//String imgPath;
String imgTitle;
String imgTitleAlt;
HtmlElement lHref;
//HtmlElement lHref;
String rawXml;
String lMemeTitle;
HtmlElement lTitleElement;
Expand All @@ -97,12 +101,12 @@ public static List<PublishedMeme> getPublishedMemes(String targetUrl)
logger.info("Meme title : <" + lMemeTitle + ">");
lMeme.setTitle(lMemeTitle);

lHref = lDivision.getFirstByXPath(".//div[@class='base-img-wrap-wrap']/div[@class='base-img-wrap']/a");
//lHref = lDivision.getFirstByXPath(".//div[@class='base-img-wrap-wrap']/div[@class='base-img-wrap']/a");
//lHref = lDivision.getFirstByXPath(".//h2[1]/a");
//HtmlElement lHref = lDivision.getFirstByXPath("//h2[@class='base-unit-title']/a");
//HtmlElement lHref = lDivision.getFirstByXPath("/html/body/div[2]/div[3]/div[6]/h2/a");
//logger.info("href : <" + lHref + ">");
imgPath = lHref.getAttribute("href");
//imgPath = lHref.getAttribute("href");
//imgTitleAlt = lHref.getAttribute("alt");
//logger.info(lHref.asXml());
//logger.info("Found href : <" + imgPath + ">");
Expand Down Expand Up @@ -219,11 +223,13 @@ public static String getNextPageUrl(String anyImgflipUrl) throws IOException {
}

public static void main(String[] args) throws Exception {
//List<PublishedMeme> memes = PublishedMemesCrawler.getPublishedMemes();
List<PublishedMeme> memes = PublishedMemesCrawler.getPublishedMemes();
//PublishedmemesCrawler.getNextPageUrl("https://imgflip.com/";//m/fun?sort=latest&after=53z8gv");
List<PublishedMeme> memes = PublishedMemesCrawler.getPublishedMemes("fun", 1);
//List<PublishedMeme> memes = PublishedMemesCrawler.getPublishedMemes("fun", 1);
int i = 1;
for (PublishedMeme aMeme : memes) {
System.out.println(aMeme);
System.out.println(i + ". " + aMeme);
i++;
}
System.exit(0);
}
Expand Down

0 comments on commit aacc715

Please sign in to comment.