Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scraper is giving generic scrap error #23

Open
JkMulti opened this issue Aug 21, 2022 · 1 comment
Open

Scraper is giving generic scrap error #23

JkMulti opened this issue Aug 21, 2022 · 1 comment

Comments

@JkMulti
Copy link

JkMulti commented Aug 21, 2022

com.arthurivanets.googleplayscraper.util.ScraperError$GenericError:

@machado001
Copy link

I was getting this same error. Try running the code inside a coroutine. Here's an example:

class MyScraper(private val scraper: GooglePlayScraper) {

    suspend fun getAppReviews() {
        withContext(Dispatchers.IO) {
            val params = GetAppReviewsParams(
                appId = "com.machado001.words",
                language = "PT",
                country = "BR",
                limit = 150
            )

            val response = scraper.getAppReviews(params).execute()

            if (response.isSuccess) {
                val reviews = response.requireResult()
                println(reviews)
            } else {
                val error = response.requireError()
                println(error)
            }
        }
    }
}
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.lifecycle.lifecycleScope
import com.arthurivanets.googleplayscraper.GooglePlayScraper
import kotlinx.coroutines.launch

class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        val scraper = GooglePlayScraper()

        lifecycleScope.launch {
            val scraperInstance = MyScraper(scraper)
            scraperInstance.getAppReviews()
        }
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants