https://github.com/shubham0204/google-search-kotlin
Get Google Search results in Kotlin
https://github.com/shubham0204/google-search-kotlin
kotlin library
Last synced: about 2 months ago
JSON representation
Get Google Search results in Kotlin
- Host: GitHub
- URL: https://github.com/shubham0204/google-search-kotlin
- Owner: shubham0204
- License: apache-2.0
- Created: 2024-06-23T15:07:24.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-07-15T01:32:07.000Z (about 1 year ago)
- Last Synced: 2025-03-17T04:15:36.654Z (7 months ago)
- Topics: kotlin, library
- Language: Kotlin
- Homepage: https://shubham0204.github.io/google-search-kotlin/google-search-kotlin/[root]/-google-search-provider/index.html
- Size: 298 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Google Search Results - Kotlin
> A simple library that provides an API to fetch Google Search results given a query to search
[](https://jitpack.io/#shubham0204/google-search-kotlin)
## Setup
The library is distributed with Jitpack. In the root `build.gradle` file, add the `jitpack` repository,
```groovy
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
```Next, add the library dependency in the module-level `build.gradle`,
```groovy
dependencies {
implementation 'com.github.shubham0204:google-search-kotlin:0.0.1'
}
```## Usage
The library provides two static methods to fetch Google Search results - `search` and `searchAsFlow`. The arguments passed to both the methods are same, except that `searchAsFlow` returns a `kotlinx.coroutines.flow.Flow` object.
```kotlin
CoroutineScope(Dispatchers.Default).launch {
val results: Flow = GoogleSearchProvider.searchAsFlow(
term = "" ,
readPageText = false ,
numResults = 10,
lang = "en",
safe = "active",
timeframe = GoogleSearchProvider.SearchTimeframe.PAST_24HOURS,
readPageText = false
)
results.collect {
println( it.title )
println( it.href )
}
}
```