Package com.hw.serpapi
Class SerpApiHttpClient
java.lang.Object
com.hw.serpapi.SerpApiHttpClient
HTTPS search for Serp API
- Author:
- HamaWhite
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected HttpURLConnection
buildConnection
(String path, Map<String, String> parameter) Build URLint
int
getResults
(Map<String, String> parameter) Get resultsvoid
setHttpConnectionTimeout
(int httpConnectionTimeout) void
setHttpReadTimeout
(int httpReadTimeout) protected void
triggerSerpApiClientException
(String content) trigger a exception on error
-
Field Details
-
VERSION
current API version -
BACKEND
backend service -
path
current backend HTTP path
-
-
Constructor Details
-
SerpApiHttpClient
Constructor- Parameters:
path
- HTTP url path
-
-
Method Details
-
buildConnection
protected HttpURLConnection buildConnection(String path, Map<String, String> parameter) throws SerpApiSearchExceptionBuild URL- Parameters:
path
- url end pointparameter
- search parameter map like: { "q": "coffee", "location": "Austin, TX"}- Returns:
- httpUrlConnection
- Throws:
SerpApiSearchException
- wraps error message
-
getResults
Get results- Parameters:
parameter
- user search parameters- Returns:
- http response body
- Throws:
SerpApiSearchException
- wraps error message
-
triggerSerpApiClientException
trigger a exception on error- Parameters:
content
- raw JSON response from serpapi.com- Throws:
SerpApiSearchException
- wraps error message
-
getHttpConnectionTimeout
public int getHttpConnectionTimeout()- Returns:
- current HTTP connection timeout
-
setHttpConnectionTimeout
public void setHttpConnectionTimeout(int httpConnectionTimeout) - Parameters:
httpConnectionTimeout
- set HTTP connection timeout
-
getHttpReadTimeout
public int getHttpReadTimeout()- Returns:
- current HTTP read timeout
-
setHttpReadTimeout
public void setHttpReadTimeout(int httpReadTimeout) - Parameters:
httpReadTimeout
- set HTTP read timeout
-