RobertGrubb / tiktok-php

TikTok scraper in PHP
MIT License
63 stars 21 forks source link

$scraper->user->video() sometimes returns false; #14

Closed AdrianoRamalho21 closed 4 years ago

AdrianoRamalho21 commented 4 years ago

Hello again Robert :)

Thank you for the Exceptions issue response and fix btw :)

Another thing I've noticed is, when you search an exiting video, with $scraper->user->video("@psg", 6848259790221741317) , for example, sometimes it returns false, but if I run the script again, I catch it, so it doesn't return false anymore....

It happens to me sometimes, it returns a https 0 code, non existing host, and the host is https://www.tiktok.com/@psg/video/6848259790221741317 , and it exists...

Sometimes, I can run the script like 5 times and only catch it on the 6th try...

I don't know what's happening, if it is the curl request, some kind of timeout, I don't know :/

You have any ideia of what might be causing this issue?

RobertGrubb commented 4 years ago

Hey @AdrianoRamalho21 -- Very interesting issue you're having.

I've been looking into this using the exact same video data you've provided here. The hard part for me personally is that I've tried it in 3 different environments now (Also 3 different IPs).

One being my local machine, one being on a VPS, and another being on a completely separate VPS with and without a proxy.

All of these have returned 10/10 results. Is there a chance they might be limiting your IP? I haven't personally ran in to any limiting issues, but that's also because I always run a proxy rotator out of the gate anymore when it comes to this kind of thing, which is why I implemented the proxy configuration early on in the scraper.

I would attempt a proxy to see if it gives you better results, you can do so by setting the following configuration:

'proxy' => [
    'protocol' => 'http',
    'address' => '127.0.0.1:8080',
    'auth' => 'username:password'
]

If the problem still persists, I will investigate more time into it.