Skip to content

Commit

Permalink
Wait if it's a rest request only
Browse files Browse the repository at this point in the history
  • Loading branch information
YoungerDryas89 committed Nov 24, 2024
1 parent caeed84 commit 0993137
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,8 @@ public static Document downloadDocumentFromURLString(String url) {

public static Connection.Response getDocument(SearchResult searchResult) {
try {
Thread.sleep(Duration.ofSeconds((int) (Math.random() * (10 - 5) + 5)));
if(searchResult.isJSONSearchResult())
Thread.sleep(Duration.ofSeconds((int) (Math.random() * (10 - 5) + 5)));
return Jsoup.connect(searchResult.getUrlPath()).userAgent(UserAgent.getRandomUserAgent()).ignoreHttpErrors(true).timeout(CONNECTION_TIMEOUT_VALUE).execute();
}catch (InterruptedException | IOException e){
System.err.println(e.getMessage());
Expand All @@ -596,7 +597,8 @@ public static Connection.Response getDocument(SearchResult searchResult) {

public Connection.Response downloadDocument(SearchResult searchResult) {
try {
Thread.sleep(Duration.ofSeconds((int) (Math.random() * (10 - 5) + 5)));
if(searchResult.isJSONSearchResult())
Thread.sleep(Duration.ofSeconds((int) (Math.random() * (10 - 5) + 5)));
return Jsoup.connect(searchResult.getUrlPath()).userAgent(UserAgent.getRandomUserAgent()).ignoreHttpErrors(true).timeout(CONNECTION_TIMEOUT_VALUE).execute();
}catch (InterruptedException | IOException e){
System.err.println(e.getMessage());
Expand Down

0 comments on commit 0993137

Please sign in to comment.