google-search-results-java
google-search-results-java copied to clipboard
Cant get this artifact from jitpack
Hello,
How do I get this library in maven? Could you please help?
This is what I have in my pom.xml:
<dependency> <groupId>com.github.serpapi</groupId> <artifactId>google-search-results-java</artifactId> <version>2.0.3</version> </dependency>
and:
<repositories> <repository> <id>jitpack.io</id> <url>https://www.jitpack.io</url> </repository> </repositories>
But I am always getting this error: [ERROR] Failed to execute goal on project xxx: Could not resolve dependencies for project xxx: The following artifacts could not be resolved: com.github.serpapi:google-search-results-java:jar:2.0.3 (absent): Could not find artifact com.github.serpapi:google-search-results-java:jar:2.0.3 in jitpack.io (https://www.jitpack.io)
Thank you!
I have encountered the same issue and hope it can be resolved. Thank you.
Any update on this? I am also experiencing this issue.
@codebyamir Temporary Solution, I copied this code into my project langchain-java and pushed it to the Maven repository. https://github.com/HamaWhiteGG/langchain-java
You can use the following Maven dependency:
<!-- https://mvnrepository.com/artifact/io.github.hamawhitegg/serpapi-client -->
<dependency>
<groupId>io.github.hamawhitegg</groupId>
<artifactId>serpapi-client</artifactId>
<version>0.1.7</version>
</dependency>
Note that it requires Java 17 or later(Because my entire project is using Java 17.).
Here is an example code:
SerpApiSearch search = new GoogleSearch();
Map<String, String> parameter = new HashMap<>();
parameter.put("engine", "google");
parameter.put("google_domain", "google.com");
parameter.put("gl", "us");
parameter.put("hl", "en");
parameter.put("q", "High temperature in SF yesterday");
search.setParameter(parameter);
JsonObject result = search.getJson();
String searchResult = result.getAsJsonArray("organic_results")
.get(0)
.getAsJsonObject()
.get("snippet")
.getAsString();
System.out.println(searchResult);
The output is like:
See weather overview. San Francisco Temperature Yesterday. Maximum temperature yesterday: 69 °F (at 2:56 pm) Minimum temperature yesterday: 54 °F (at 4:56 am)
@jvmvik, may https://github.com/serpapi/google-search-results-java/pull/3 fix the artifacts downloading?
Edit:
@ai-for-java @codebyamir @HamaWhiteGG Follow the next steps to get artifacts from the jitpack:
- Add
repository
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
- Add
classifier
to thedependency
. (The package name contains the suffix:google-search-results-java-2.0.3-sources.jar
.)
<dependency>
<groupId>com.github.serpapi</groupId>
<artifactId>google-search-results-java</artifactId>
<version>2.0.3</version>
<classifier>sources</classifier>
</dependency>
- Compile the project following the Maven's magic
mvn clean install dependency:copy-dependencies package && javac -classpath .:target/dependency/* -d . $(find . -type f -name '*.java')`
- Run the code
java -cp .:target/dependency/* Main
Full example:
- Code: https://replit.com/@ilyazub/serpapi-google-search-results-java-maven#Main.java
- pom.xml: https://replit.com/@ilyazub/serpapi-google-search-results-java-maven#pom.xml
- Compilation and execution scripts: https://replit.com/@ilyazub/serpapi-google-search-results-java-maven#.replit