Skip to content

Commit

Permalink
Changed headless wait selectors
Browse files Browse the repository at this point in the history
  • Loading branch information
Flameish committed May 16, 2020
1 parent 1374bd9 commit 6a2cb15
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/grabber/Driver.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public List<Chapter> getChapterList() {
chapterShow.selectByVisibleText("All");
break;
case "https://comrademao.com/":
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("/html/body/nav/label/ul/li[3]/a")));
wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector(novel.host.bookDescSelector)));
// Parse html from headerless to Jsoup for faster interaction.
String baseUrl = driver.getCurrentUrl().substring(0, GrabberUtils.ordinalIndexOf(driver.getCurrentUrl(), "/", 3) + 1);
// Save table of contents doc for metadata extraction later on
Expand All @@ -91,6 +91,7 @@ public List<Chapter> getChapterList() {
}
return chapters;
case "https://creativenovels.com/":
wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("ul[role='tablist'] > li:nth-of-type(3) button")));
driver.findElement(By.cssSelector("ul[role='tablist'] > li:nth-of-type(3) button")).click();
wait.until(ExpectedConditions.presenceOfElementLocated(By.cssSelector(".post_box")));
break;
Expand All @@ -104,6 +105,7 @@ public List<Chapter> getChapterList() {
wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector(".chapter-list a")));
break;
case "https://wordexcerpt.com/":
wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("li.nav-item:nth-child(2) > a:nth-child(1)")));
driver.findElement(By.cssSelector("li.nav-item:nth-child(2) > a:nth-child(1)")).click();
wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector(novel.host.chapterLinkSelector)));
break;
Expand All @@ -117,13 +119,16 @@ public List<Chapter> getChapterList() {
driver.findElement(By.cssSelector(".chapter-readmore")).click();
break;
case "https://wordrain69.com/":
wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector(".chapter-readmore")));
driver.findElement(By.cssSelector(".chapter-readmore")).click();
wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector(novel.host.chapterLinkSelector)));
break;
case "https://ficfun.com/":
wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector(".button-round-red")));
driver.findElement(By.cssSelector(".button-round-red")).click();
break;
case "https://dreame.com/":
wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector(".button-round-purple")));
driver.findElement(By.cssSelector(".button-round-purple")).click();
break;
case "https://wuxiaworld.site/":
Expand Down

0 comments on commit 6a2cb15

Please sign in to comment.