davidteather / TikTok-Api

The Unofficial TikTok API Wrapper In Python
https://davidteather.github.io/TikTok-Api
MIT License
4.83k stars 969 forks source link

After first success .TikTok blocks this request displaying a Captcha . #388

Closed LSSCP closed 3 years ago

LSSCP commented 3 years ago

I just updated to the newest version and followed the first example to check if it works.

It works..but only once...is there any advice?

thank you.

code:

from TikTokApi import TikTokApi results = 10 api = TikTokApi.get_instance() verifyFp = 'verify_xxxxxxxxxxx' proxy_address = 'http://127.0.0.1:1111' trending = api.trending(count=results, custom_verifyFp=verifyFp, proxy=proxy_address) for tiktok in trending: print(tiktok['id'])

I got this response immediately after first success.

TikTokApi.exceptions.TikTokCaptchaError: TikTok blocks this request displaying a Captcha Tip: Consider using a proxy or a custom_verifyFp as method parameters

davidteather commented 3 years ago

Might want to slow down your requests or use a service like luminati.io which lets you use proxies exclusively on m.tiktok.com and then it distributes the requests you make to it across multiple servers

reccardt commented 3 years ago

It worked for me early yesterday, but now the browser no longer brings up the slider captcha. I log in to my own account using Chrome Incognito mode and as before I solve the shape captcha. Until today, if I clicked on For You or Following I would be presented with the slider captcha, I would solve it, add the cookie to custom_verifyFp and the code worked. Today I'm no longer seeing the slider captcha in the browser but getData is requiring it.

reccardt commented 3 years ago

The above issue was when calling trending. But discoverMusic works with the same cookie.

reccardt commented 3 years ago

Now I tried FireFox. No slider captcha either but the cookie worked for trending. What am I missing?

chasingrainbows commented 3 years ago

Have the same problem, after migration to playwright, library just no longer working. Return to Pyppeteer version of lib https://github.com/TikTokApi-Pyppeteer/TikTok-Api-Pyppeteer solved this problem for me, for now.

AlexVerrico commented 3 years ago

Posting in case it helps anyone else with the same issue: I couldn't manage to get it to work using Brave browser to get the cookie, for some reason I had to use Chrome to get the cookie and then it worked perfectly.

larrylee1994 commented 3 years ago

Yes I was having this exact issue. Getting a cookie right after using the slider always works for me. To re produce this I would delete the cookie to trigger the slider. Today deleting the cookie is not producing a slider on chrome. It creates another custom verify, but it didn't work. I switched to Firefox and I got a slider and the cookie worked as expected.

davidteather commented 3 years ago

I'll update some info you might want to look at this to force captchas but for me it doesn't generate valid s_v_web_id cookies everytime for some reason I imagine they're doing some kind of browser fingerprinting as even on tor with switching nodes it doesn't work :\

See #347 for more info

nuqz commented 3 years ago

I'm very sorry for spamming in every issue, but I can’t help myself, the problem is very acute. As I mentioned in #397 I have a working solution for solving captchas (puzzle sliders). I will be able to share the tool (Python and PyTorch based, something like this) if someone tells me exact requests limits, i.e. I need a solution for this carcabot/tiktok-signature issue#105. I did some research, I already have where to start.

davidteather commented 3 years ago

@nuqz I recommend using something like luminati.io as a proxy it'll rotate IPs for pretty cheap. Also at least for now you can do api = TikTokApi.get_instance(use_test_endpoints=True) which makes requests to t.tiktok.com instead of m.tiktok.com which has less secure endpoints although I can't guarantee how long that'll last.

nuqz commented 3 years ago

@davidteather thank you for suggestions. I didn't know about test endpoint. Our team has already tried options with different proxy rotators, but sooner or later, all proxy IP addresses will be totally banned (empty responses with status 200) or will be marked to be protected by captcha. We have come to the conclusion that it is better to respect the service rate limits.

davidteather commented 3 years ago

@nuqz I’d make sure your cookie generator is actually generating valid cookies. TikTok has been finger printing the browsers and probably mark cookies generated as invalid

nuqz commented 3 years ago

@davidteather I do not fully understand what you are talking about. May I ask you to point me to a right place in the code/comments?

davidteather commented 3 years ago

@nuqz it would be an issue with your captcha solver. There’s a ratelimiter on a per cookie basis I believe. If you make too many requests with a given cookie that’s when you hit empty body exceptions. Also ensure your s_v_webid / verifyFp are valid as if your cookie generator code is poorly setup that means it’ll generate invalid s_v_webid cookies resulting in empty body responses

reccardt commented 3 years ago

What is a reasonable value to supply to request_delay?

nuqz commented 3 years ago

@davidteather thank you for the new insight. I'll try to update cookies more often.

davidteather commented 3 years ago

What is a reasonable value to supply to request_delay?

Don't really know maybe try 1 or 2 which are seconds

If anyone is having this issue further try to add the use_test_endpoints param to the constructor. Ex: TikTokApi.get_instance(use_test_endpoints=True) which seems to help. There's a YouTube video in the readme that explains what this does better

SoshlikKiller commented 3 years ago

Sorry, but something is not very clear to me, is there some simple solution to this error? (Sorry, I'm stupid :c ) :

TikTokApi.exceptions.TikTokCaptchaError: TikTok blocks this request displaying a Captcha Tip: Consider using a proxy or a custom_verifyFp as method parameters

davidteather commented 3 years ago

I recommend watching the YouTube video linked in the readme

SoshlikKiller commented 3 years ago

Thanks, I duplicated the code exactly, but the error is the same

ejxtreme512 commented 3 years ago

I recently started getting this error - any suggestions on best way to fix?

EwenBernard commented 1 year ago

To bypass captcha error, use a tiktok captcha solver like this : https://github.com/xtekky/TikTok-Captcha-Solver