Add cloudflare detection
This commit is contained in:
parent
f87dd17bae
commit
5e02645dd3
2 changed files with 5 additions and 1 deletions
|
@ -84,6 +84,9 @@ class ErrorInterceptor(
|
|||
throw ScrapperException(doc.select("#MainDiv > div").text())
|
||||
}
|
||||
"Połączenie zablokowane" -> throw ConnectionBlockedException(doc.body().text())
|
||||
"Just a moment..." -> if (doc.select(".footer").text().contains("Cloudflare")) {
|
||||
throw ConnectionBlockedException(doc.select("#challenge-body-text").text())
|
||||
}
|
||||
"Przerwa techniczna" -> throw ServiceUnavailableException(doc.title())
|
||||
"Strona nie została odnaleziona" -> throw ScrapperException(doc.title())
|
||||
"Strona nie znaleziona" -> throw ScrapperException(doc.selectFirst("div div")?.text().orEmpty())
|
||||
|
|
|
@ -17,7 +17,8 @@ class HttpErrorInterceptor : Interceptor {
|
|||
return when (response.code) {
|
||||
429 -> throw NotLoggedInException(response.body?.string() ?: response.message)
|
||||
404 -> throw ScrapperException(response.code.toString() + ": " + response.message)
|
||||
in 400..499 -> throw VulcanClientError(response.code.toString() + ": " + response.body?.string(), response.code)
|
||||
in 400..402 -> throw VulcanClientError(response.code.toString() + ": " + response.body?.string(), response.code)
|
||||
in 404..499 -> throw VulcanClientError(response.code.toString() + ": " + response.body?.string(), response.code)
|
||||
in 500..599 -> throw ServiceUnavailableException(response.code.toString() + ": " + response.message)
|
||||
else -> response
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue