public class Site extends Object
PageProcessor
Constructor and Description |
---|
Site() |
Modifier and Type | Method and Description |
---|---|
Site |
addCookie(String name,
String value)
Add a cookie with domain
getDomain() |
Site |
addCookie(String domain,
String name,
String value)
Add a cookie with specific domain.
|
Site |
addHeader(String key,
String value)
Put an Http header for downloader.
|
boolean |
equals(Object o) |
Set<Integer> |
getAcceptStatCode()
get acceptStatCode
|
Map<String,Map<String,String>> |
getAllCookies()
get cookies of all domains
|
String |
getCharset()
get charset set manually
|
Map<String,String> |
getCookies()
get cookies
|
int |
getCycleRetryTimes()
When cycleRetryTimes is more than 0, it will add back to scheduler and try download again.
|
String |
getDomain()
get domain
|
Map<String,String> |
getHeaders() |
int |
getRetrySleepTime() |
int |
getRetryTimes()
Get retry times immediately when download fail, 0 by default.
|
int |
getSleepTime()
Get the interval between the processing of two pages.
Time unit is micro seconds. |
int |
getTimeOut() |
String |
getUserAgent()
get user agent
|
int |
hashCode() |
boolean |
isDisableCookieManagement() |
boolean |
isUseGzip() |
static Site |
me()
new a Site
|
Site |
setAcceptStatCode(Set<Integer> acceptStatCode)
Set acceptStatCode.
When status code of http response is in acceptStatCodes, it will be processed. {200} by default. It is not necessarily to be set. |
Site |
setCharset(String charset)
Set charset of page manually.
When charset is not set or set to null, it can be auto detected by Http header. |
Site |
setCycleRetryTimes(int cycleRetryTimes)
Set cycleRetryTimes times when download fail, 0 by default.
|
Site |
setDisableCookieManagement(boolean disableCookieManagement)
Downloader is supposed to store response cookie.
|
Site |
setDomain(String domain)
set the domain of site.
|
Site |
setRetrySleepTime(int retrySleepTime)
Set retry sleep times when download fail, 1000 by default.
|
Site |
setRetryTimes(int retryTimes)
Set retry times when download fail, 0 by default.
|
Site |
setSleepTime(int sleepTime)
Set the interval between the processing of two pages.
Time unit is micro seconds. |
Site |
setTimeOut(int timeOut)
set timeout for downloader in ms
|
Site |
setUseGzip(boolean useGzip)
Whether use gzip.
|
Site |
setUserAgent(String userAgent)
set user agent
|
String |
toString() |
Task |
toTask() |
public static Site me()
public Site addCookie(String name, String value)
getDomain()
name
- namevalue
- valuepublic Site addCookie(String domain, String name, String value)
domain
- domainname
- namevalue
- valuepublic Site setUserAgent(String userAgent)
userAgent
- userAgentpublic Map<String,Map<String,String>> getAllCookies()
public String getUserAgent()
public String getDomain()
public Site setDomain(String domain)
domain
- domainpublic Site setCharset(String charset)
charset
- charsetpublic String getCharset()
public int getTimeOut()
public Site setTimeOut(int timeOut)
timeOut
- timeOutpublic Site setAcceptStatCode(Set<Integer> acceptStatCode)
acceptStatCode
- acceptStatCodepublic Set<Integer> getAcceptStatCode()
public Site setSleepTime(int sleepTime)
sleepTime
- sleepTimepublic int getSleepTime()
public int getRetryTimes()
public Site addHeader(String key, String value)
addCookie(String, String)
for cookie and setUserAgent(String)
for user-agent. key
- key of http header, there are some keys constant in HttpConstant.Header
value
- value of headerpublic Site setRetryTimes(int retryTimes)
retryTimes
- retryTimespublic int getCycleRetryTimes()
public Site setCycleRetryTimes(int cycleRetryTimes)
cycleRetryTimes
- cycleRetryTimespublic boolean isUseGzip()
public int getRetrySleepTime()
public Site setRetrySleepTime(int retrySleepTime)
retrySleepTime
- retrySleepTimepublic Site setUseGzip(boolean useGzip)
useGzip
- useGzippublic boolean isDisableCookieManagement()
public Site setDisableCookieManagement(boolean disableCookieManagement)
disableCookieManagement
- disableCookieManagementpublic Task toTask()
Copyright © 2017. All rights reserved.