Package com.hw.serpapi
Class SerpApiSearch
java.lang.Object
com.hw.serpapi.SerpApiSearch
- Direct Known Subclasses:
GoogleSearch
Due to Cant get this artifact from jitpack, I decided to add the serpapi-client module myself.
SerpApiSearch wraps HTTP interaction with the service serpapi.com
- Author:
- HamaWhite
-
Field Summary
-
Constructor Summary
ConstructorDescriptionSerpApiSearch
(String engine) Constructor with no parameterSerpApiSearch
(String serpapiApiKey, String engine) ConstructorSerpApiSearch
(Map<String, String> parameter, String engine) ConstructorConstructor -
Method Summary
Modifier and TypeMethodDescriptioncom.google.gson.JsonObject
Convert HTTP content to JsonValuebuildQuery
(String path, String output) Build a serp API query by expanding existing parametercom.google.gson.JsonObject
Get account information using Account APIstatic String
getHtml()
Get HTML outputcom.google.gson.JsonObject
getJson()
Get JSON outputcom.google.gson.JsonArray
getLocation
(String q, Integer limit) Get locationcom.google.gson.JsonObject
getSearchArchive
(String searchID) Get search result from the Search Archive APIvoid
setParameter
(Map<String, String> parameter)
-
Field Details
-
API_KEY_NAME
Set of constant- See Also:
-
serpapiApiKey
user secret API key -
engine
Current search engine -
parameter
search parameters -
search
https search implementation for Java 7+
-
-
Constructor Details
-
SerpApiSearch
Constructor- Parameters:
parameter
- user searchserpapiApiKey
- secret user API keyengine
- service like: google, naver, yahoo...
-
SerpApiSearch
Constructor- Parameters:
parameter
- user searchengine
- service like: google, yahoo, bing...
-
SerpApiSearch
Constructor with no parameter- Parameters:
engine
- service like: google, bing, yahoo...
-
SerpApiSearch
Constructor- Parameters:
serpapiApiKey
- secret API keyengine
- service like: google, bing, yahoo...
-
-
Method Details
-
buildQuery
Build a serp API query by expanding existing parameter- Parameters:
path
- backend HTTP pathoutput
- type of output format (json, html, json_with_images)- Returns:
- format parameter hash map
- Throws:
SerpApiSearchException
- wraps backend error message
-
getApiKeyFromEnv
- Returns:
- current secret api key
-
getHtml
Get HTML output- Returns:
- raw HTML response from the search engine for custom parsing
- Throws:
SerpApiSearchException
- wraps backend error message
-
getJson
Get JSON output- Returns:
- JsonObject parent node
- Throws:
SerpApiSearchException
- wraps backend error message
-
asJson
Convert HTTP content to JsonValue- Parameters:
content
- raw JSON HTTP response- Returns:
- JsonObject created by gson parser
-
getClient
- Returns:
- http search
-
getLocation
Get location- Parameters:
q
- querylimit
- number of location- Returns:
- JsonObject location using Location API
- Throws:
SerpApiSearchException
- wraps backend error message
-
getSearchArchive
Get search result from the Search Archive API- Parameters:
searchID
- archived search result = search_metadata.id- Returns:
- JsonObject search result
- Throws:
SerpApiSearchException
- wraps backend error message
-
getAccount
Get account information using Account API- Returns:
- JsonObject account information
- Throws:
SerpApiSearchException
- wraps backend error message
-
setParameter
-