Skip to content

Commit

Permalink
Update HunterIoClient.java
Browse files Browse the repository at this point in the history
  • Loading branch information
bit4woo committed Apr 19, 2024
1 parent 6de5b89 commit d4a7730
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/InternetSearch/Client/HunterIoClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import InternetSearch.SearchEngine;
Expand Down Expand Up @@ -37,7 +38,12 @@ public List<SearchResultEntry> parseResp(String respbody) {
JSONObject entryitem = (JSONObject) item;
JSONArray sources = entryitem.getJSONArray("sources");
String email = entryitem.getString("value");
String position = entryitem.getString("position");
String position = null;
try {
position = entryitem.getString("position");
} catch (JSONException e) {

}

for (Object source:sources){
JSONObject sourceitem = (JSONObject) source;
Expand All @@ -46,7 +52,9 @@ public List<SearchResultEntry> parseResp(String respbody) {
entry.setUri(url);
entry.setRootDomain(email);
entry.setSource(getEngineName());
entry.setTitle(position);
if (StringUtils.isNotEmpty(position)){
entry.setTitle(position);
}
result.add(entry);
}
}
Expand Down Expand Up @@ -85,7 +93,7 @@ public String buildSearchUrl(String searchContent, int page) {
}
int offset = pageSize *(page-1);
String url = String.format(
"https://api.hunter.io/v2/domain-search?domain=%s&offset=%s",searchContent,offset);
"https://api.hunter.io/v2/domain-search?api_key=%s&domain=%s&offset=%s",key,searchContent,offset);
return url;
}

Expand Down

0 comments on commit d4a7730

Please sign in to comment.