-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix Google Scholar fetcher for downloading a single entry #7075
Closed
Closed
Changes from 3 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
4c25a1d
Fix Google Scholar fetcher for downloading a single entry
koppor 3f389c4
Merge remote-tracking branch 'origin/master' into refine-google-scholar
koppor 90efdd1
Shrink scopy of try...catch
koppor 531fcad
Remove fetching of 10 more results if exactly 10 results are fetched …
koppor 4fcfb61
Add 403
koppor 60c74e1
Compile fix
koppor f3488e2
Have obtainAndModifiycookie patch the URL download (and not create a …
koppor 62a5100
Keep order of terms when transforming the query
koppor 07e93f4
Improve logger and initial ArrayList size
koppor 9cad830
Refine caught exceptions
koppor f504609
Fix typo
koppor 6775728
Fix Google Scholar: Show "allintitle:" only if title is present
koppor b691aed
Working on adding the CaptchaSolver
koppor f34d7f8
Merge remote-tracking branch 'origin/master' into refine-google-scholar
koppor 5051e1b
Chagne order
koppor 625778f
CaptchaDialog for the first step
koppor File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
56 changes: 56 additions & 0 deletions
56
src/main/java/org/jabref/gui/dialogs/CaptchaSolverDialog.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package org.jabref.gui.dialogs; | ||
|
||
import java.util.concurrent.CountDownLatch; | ||
|
||
import javafx.application.Platform; | ||
import javafx.scene.control.ButtonType; | ||
import javafx.scene.web.WebView; | ||
|
||
import org.jabref.gui.util.BaseDialog; | ||
import org.jabref.logic.l10n.Localization; | ||
import org.jabref.logic.net.URLDownload; | ||
|
||
import org.jsoup.helper.W3CDom; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.w3c.dom.Document; | ||
|
||
public class CaptchaSolverDialog extends BaseDialog<String> implements org.jabref.logic.importer.fetcher.CaptchaSolver { | ||
|
||
public static final Logger LOGGER = LoggerFactory.getLogger(CaptchaSolverDialog.class); | ||
|
||
private WebView webView; | ||
|
||
public CaptchaSolverDialog() { | ||
super(); | ||
this.setTitle(Localization.lang("Captcha Solver")); | ||
getDialogPane().getButtonTypes().add(ButtonType.CLOSE); | ||
getDialogPane().lookupButton(ButtonType.CLOSE).setVisible(true); | ||
|
||
webView = new WebView(); | ||
webView.getEngine().setJavaScriptEnabled(true); | ||
webView.getEngine().setUserAgent(URLDownload.USER_AGENT); | ||
getDialogPane().setContent(webView); | ||
} | ||
|
||
@Override | ||
public String solve(String queryURL) { | ||
// slim implementation of https://news.kynosarges.org/2014/05/01/simulating-platform-runandwait/ | ||
final CountDownLatch doneLatch = new CountDownLatch(1); | ||
Platform.runLater(() -> { | ||
webView.getEngine().load(queryURL); | ||
// For the quick implementation, we ignore the result | ||
// Later, at "webView", we directly extract it from the web view | ||
this.showAndWait(); | ||
doneLatch.countDown(); | ||
}); | ||
try { | ||
doneLatch.await(); | ||
Document document = webView.getEngine().getDocument(); | ||
return W3CDom.asString(document, null); | ||
} catch (InterruptedException e) { | ||
LOGGER.error("Issues with the UI", e); | ||
} | ||
return ""; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
src/main/java/org/jabref/logic/importer/fetcher/NoneCaptchaSolver.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package org.jabref.logic.importer.fetcher; | ||
|
||
public class NoneCaptchaSolver implements CaptchaSolver { | ||
@Override | ||
public String solve(String queryURL) { | ||
return ""; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to listen for the web engine ready event, see the preview Tab viewer where we add this highlight ja stuff
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See https://openjfx.io/javadoc/11/javafx.web/javafx/scene/web/WebEngine.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this happen synchronously? The interface for the Captcha solver is designed in a synchronous way. Otherwise all fetchers need to be changed.
I'll be away anyway for the next days. Thus, you are free to experiment 😅