From a0d9555332ead380bf9fc4acb35d74bdbaa4604b Mon Sep 17 00:00:00 2001 From: Hilman Ramadhan <4522467+hilmanski@users.noreply.github.com> Date: Thu, 5 Jun 2025 13:02:44 +0800 Subject: [PATCH] Update README.md Include the generic `SerpApiSearch` class instruction --- README.md | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d408063..71f1914 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ https://jitpack.io/api/builds/com.github.serpapi/google-search-results-java Note: jitpack.io enables to download maven package directly from github release. -## Quick start +## Quick start for Google Search To get started with this project in Java. We provided a fully working example. @@ -101,6 +101,30 @@ The class GoogleSearch - Parse JSON into Ruby Hash using JSON standard library provided by Ruby Et voila.. +## Usage for other search engines +For other search engines, you can use the `SerpApiSearch` class and adjust the `engine`. +Example for our Google Lens API: + +``` +public void runSearch() { + Map parameter = new HashMap<>(); + + parameter.put("engine", "google_lens"); // You can adjust the engine here + parameter.put("url", "https://i.imgur.com/HBrB8p0.png"); + parameter.put("api_key", serpApiKey); + + SerpApiSearch search = new SerpApiSearch(parameter); // Use SerpApiSearch class + + try { + JsonObject results = search.getJson(); + JsonElement searchResults = results.get("visual_matches"); + System.out.println(searchResults); + } catch (SerpApiSearchException e) { + e.printStackTrace(); + } + } +``` + Alternatively, you can search: - Bing using BingSearch class - Baidu using BaiduSearch class