Skip to content

Instantly share code, notes, and snippets.

@emmanuj
Created December 20, 2018 01:50
Show Gist options
  • Save emmanuj/0bde6dec96d94caaa3b8c78e5e586ede to your computer and use it in GitHub Desktop.
Save emmanuj/0bde6dec96d94caaa3b8c78e5e586ede to your computer and use it in GitHub Desktop.
def submitGoogleRequest(RecordBean record, String callback_headers) throws IOException {
String query = "${record.getName()} ${record.getCompany()} ${GOOGLE_QUERY_SUFFIX}"
final URI google_uri = new URIBuilder()
.setScheme("https")
.setHost(GOOGLE_URL)
.setParameter("q",query).build()
final URI uri = new URIBuilder()
.setScheme("https")
.setHost(proxyCrawlHost)
.setParameter("token", token)
.setParameter("callback", "true")
.setParameter("crawler", "Google")
.setParameter("callback_headers", callback_headers)
.setParameter("url", google_uri.toString())
.setParameter("format", "json")
.build()
Request request = new Request.Builder()
.url(uri.toString())
.get()
.build()
Response response = httpClient.newCall(request).execute()
return response.body().string()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment