public abstract class AbstractScrapingHttpClient extends java.lang.Object implements ScrapingHttpClient
Modifier and Type | Field and Description |
---|---|
static java.util.concurrent.locks.ReentrantReadWriteLock |
GLOBAL_REQUESTS_THREAD_LOCK
A lock used globally by AbstractScrapingHttpClients so an external source can lock the write lock to block all request access temporarily.
|
protected ScrapingSession |
session |
REDIRECT_WITH_POST_ENTITY_STATUS_CODE
Modifier | Constructor and Description |
---|---|
protected |
AbstractScrapingHttpClient(ScrapingSession session)
Creates the client
|
Modifier and Type | Method and Description |
---|---|
ScrapingRequest.Builder |
convertScrapeableFileToRequest(ScrapeableFile scrapeableFile)
Converts the scrapeable file to the request.
|
protected ScrapingProxy |
getProxy()
Returns the proxy server that should be used for requests (this can change on each call)
|
protected boolean |
isRedirectStatusCode(int statusCode)
Checks if the given status code indicates a redirect
|
ScrapingResponse |
issueRequest(ScrapingRequest request)
Issues the given request
|
protected abstract ScrapingResponse |
issueRequestInternal(ScrapingRequest request)
Issues the given request.
|
protected void |
logDebug(java.lang.String message) |
protected void |
logDebug(java.lang.String message,
java.lang.Throwable throwable) |
protected void |
logError(java.lang.String message) |
protected void |
logError(java.lang.String message,
java.lang.Throwable throwable) |
protected void |
logInfo(java.lang.String message) |
protected void |
logInfo(java.lang.String message,
java.lang.Throwable throwable) |
protected void |
logWarn(java.lang.String message) |
protected void |
logWarn(java.lang.String message,
java.lang.Throwable throwable) |
ScrapingData |
scrapeFile(ScrapeableFile scrapeableFile)
Requests data for a scrapeable file.
|
void |
setProxyServer(ScrapingProxy proxyServer)
Sets a proxy server to use for future requests
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
clearCookies, close, getCookies, setCookie, updateSessionClientInfo, usesHint
public static final java.util.concurrent.locks.ReentrantReadWriteLock GLOBAL_REQUESTS_THREAD_LOCK
@Nullable protected final ScrapingSession session
protected AbstractScrapingHttpClient(@Nullable ScrapingSession session)
session
- The session@NotNull public final ScrapingResponse issueRequest(@NotNull ScrapingRequest request)
issueRequest
in interface ScrapingHttpClient
request
- The request to be issued@NotNull protected abstract ScrapingResponse issueRequestInternal(@NotNull ScrapingRequest request)
request
- The request to be issued@Nullable protected final ScrapingProxy getProxy()
public ScrapingRequest.Builder convertScrapeableFileToRequest(@NotNull ScrapeableFile scrapeableFile)
ScrapingHttpClient
return
super.convertScrapeableFileToRequest(scrapeableFile).addHeader("Cookie: " + someCookie)
convertScrapeableFileToRequest
in interface ScrapingHttpClient
scrapeableFile
- The scrapeable file to convertprotected final void logDebug(@NotNull java.lang.String message)
protected final void logDebug(@NotNull java.lang.String message, @Nullable java.lang.Throwable throwable)
protected final void logInfo(@NotNull java.lang.String message)
protected final void logInfo(@NotNull java.lang.String message, @Nullable java.lang.Throwable throwable)
protected final void logWarn(@NotNull java.lang.String message)
protected final void logWarn(@NotNull java.lang.String message, @Nullable java.lang.Throwable throwable)
protected final void logError(@NotNull java.lang.String message)
protected final void logError(@NotNull java.lang.String message, @Nullable java.lang.Throwable throwable)
public void setProxyServer(@Nullable ScrapingProxy proxyServer)
setProxyServer
in interface ScrapingHttpClient
proxyServer
- The proxy server to use for future requestspublic final ScrapingData scrapeFile(@NotNull ScrapeableFile scrapeableFile)
convertScrapeableFileToRequest(ScrapeableFile)
method and the issue request methodscrapeFile
in interface ScrapingHttpClient
scrapeableFile
- The scrapeable file to requestprotected boolean isRedirectStatusCode(int statusCode)
statusCode
- The status code