Skip to content

Commit

Permalink
Fix category data fetch throw error on first timeout retry.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sheep-y committed Dec 17, 2016
1 parent a3e2ad6 commit 41998ca
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion java/db4e/controller/Controller.java
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ private void downloadCategory() throws Exception { // Too many exceptions to thr

runAndGet( "Getting " + name + " template", () ->
crawler.getCategoryXsl( category ) );
Document xsl = engine.getDocument();
Document xsl = crawler.getCategoryXsl();

runAndGet( "Getting " + name + " data", () ->
crawler.getCategoryData( category ) );
Expand Down
7 changes: 6 additions & 1 deletion java/db4e/controller/Crawler.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import javafx.application.Platform;
import javafx.scene.web.WebEngine;
import netscape.javascript.JSObject;
import org.w3c.dom.Document;
import sheepy.util.JavaFX;

/**
Expand Down Expand Up @@ -89,9 +90,13 @@ void getCategoryXsl ( Category cat ) {
browse( "http://www.wizards.com/dndinsider/compendium/xsl/" + cat.id + ".xsl" );
}

void getCategoryData ( Category cat ) throws InterruptedException, TimeoutException {
Document getCategoryXsl () throws InterruptedException, TimeoutException {
// Update XSL's limit
eval( " document.querySelector( '[name=endPos]' ).setAttribute( 'select', \"'99999'\" ) " );
return browser.getDocument();
}

void getCategoryData ( Category cat ) {
browse( "http://www.wizards.com/dndinsider/compendium/CompendiumSearch.asmx/ViewAll?tab=" + cat.id );
}

Expand Down

0 comments on commit 41998ca

Please sign in to comment.