google-search-results-java icon indicating copy to clipboard operation
google-search-results-java copied to clipboard

Update README.md to include SerpApiSearch sample

Open hilmanski opened this issue 7 months ago • 2 comments

Many customers are confused about how to use this library with other search engines outside Google Search. This PR includes the generic SerpApiSearch class instruction.

For example: https://github.com/serpapi/google-search-results-java/issues/23

hilmanski avatar Jun 05 '25 05:06 hilmanski

Thank you @tanys123 for the feedback. I haven't been able to test it locally. Still struggling with installing this library.

hilmanski avatar Jun 09 '25 08:06 hilmanski

Thank you @tanys123 for the feedback. I haven't been able to test it locally. Still struggling with installing this library.

Yea, it is not a straightforward one, I guess we should take some time to clean up the repo. I was also banging here and there to get it to work.

I am able to get it to work this way:

  1. Following the Makefile in the /demo folder, you should first run init clean then build (yea, not dep).
  2. Even though you get error from build step, but the java library files should be downloaded in the ${root}/build folder, then this time run dep -- if it fails, just manually copy the libs folder into /demo
  3. Update the dependencies settings in build.gradle. The important part is to replace the remote repo with the local version (implementation fileTree(dir: "./libs", includes: ['*.jar']))
--- a/demo/build.gradle
+++ b/demo/build.gradle
 dependencies {
-    // implementation fileTree(dir: "./libs", includes: ['*.jar'])
+    // Use local JAR files from libs directory
+    implementation fileTree(dir: "./libs", includes: ['*.jar'])
     implementation group: 'com.google.code.gson', name: 'gson', version: '2.8.5'
-    implementation 'com.github.serpapi:google-search-results-java:2.0.3'
 }
  1. Now running make build should work, which mean running make run should work too.

tanys123 avatar Jun 10 '25 04:06 tanys123