cloudflare-scrape-Android icon indicating copy to clipboard operation
cloudflare-scrape-Android copied to clipboard

Getting "Retries exceeded the limit" message with error code 260 when using library

Open carlos-mg89 opened this issue 3 years ago • 5 comments

Hi!

First of all, I appreciate very much your efforts to make scrapping a Cloudflare based website possible.

My situation is the following one. I have setup an Android project and in the Main Activity, I'm trying to use your package as described in the main page.

So these are my steps:

  1. Edit app gradle with: implementation 'com.zhkrb.cloudflare-scrape-android:scrape-webview:0.0.4' as described in the README
  2. Add the following code in MainActivity (at the end of the onCreate() method):
val cloudFlare = Cloudflare(this, "https://www.autodoc.es/repuestos");
        cloudFlare.user_agent = "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:86.0) Gecko/20100101 Firefox/86.0";
        cloudFlare.setCfCallback(object : CfCallback {
            override
            fun onSuccess(
                cookieList: List<HttpCookie>,
                hasNewUrl: Boolean,
                newUrl: String
            ) {
                val check = true
            }

            override
            fun onFail(
                code: Int,
                msg: String
            ) {
                val check = false
            }
        })
        cloudFlare.getCookies()

I have added 2 breakpoints in the onSuccess() and in the onFail() methods, and the result is always the same. The code gets to the onFail() method, with code => 260 and msg => "Retries exceeded the limit".

Perhaps CloudFlare has done any changes recently? I can see the latest release of your library was done in February 2021, so quite recently.

Thanks in advance!

carlos-mg89 avatar Mar 22 '21 15:03 carlos-mg89

I'm checking.

You can try this demo test first, it works for my test

zhkrb avatar Mar 22 '21 16:03 zhkrb

Oh, I know the problem. The cookie you set will make the website not return cf_clearance cookie.

Try to set mobile user-agent like Mozilla/5.0 (Linux; Android 6.0.1; SM-G920V Build/MMB29K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.98 Mobile Safari/537.36

zhkrb avatar Mar 22 '21 16:03 zhkrb

Thanks for getting back :)

Do I have to add cf_clearance anywhere?

I've tried with the User Agent you've proposed, but cannot make it to the onSuccess callback...

carlos-mg89 avatar Mar 22 '21 17:03 carlos-mg89

no, cf_clearanceare required to bypass cf.

This looks like a problem with my insufficient test samples, but I don’t have time these days.

Will try to start fix bug on friday

zhkrb avatar Mar 23 '21 16:03 zhkrb

no, cf_clearanceare required to bypass cf.

This looks like a problem with my insufficient test samples, but I don’t have time these days.

Will try to start fix bug on friday

Hello, problem is still again, but changing user agent dont help (

pixkk avatar Sep 07 '22 13:09 pixkk