davidteather / TikTok-Api

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

[BUG] - 'browser' object has no attribute 'verifyFp' #237

Closed demalem closed 3 years ago

demalem commented 4 years ago

When running the example code from the README:

from TikTokApi import TikTokApi api = TikTokApi()

results = 10

trending = api.trending(count=results)

for tiktok in trending:

Prints the text of the tiktok

print(tiktok['desc'])

print(len(trending))

I recieve the below error:

AttributeError: 'browser' object has no attribute 'verifyFp'

I installed chromedriver, but may not have added it to the right path. Can you give guidance in this regards?

issue-label-bot[bot] commented 4 years ago

Issue-Label Bot is automatically applying the label bug to this issue, with a confidence of 0.94. Please mark this comment with :thumbsup: or :thumbsdown: to give our bot feedback!

Links: app homepage, dashboard and code for this bot.

duplicate-issues[bot] commented 4 years ago

Hey @demalem,

We did a quick check and this issue looks very darn similar to

This could be a coincidence, but if any of these issues solves your problem then I did a good job :smile:

If not, the maintainers will get to this issue shortly.

Cheers, Your Friendly Neighborhood ProBot

davidteather commented 4 years ago

What happens when you type the following command into your terminal

chromedriver
demalem commented 4 years ago

'chromedriver' is not recognized as an internal or external command, operable program or batch file.

However, I downloaded chromedriver and included in the path where the script is located. Both in C:\Users\emela.spyder-py3

demalem commented 4 years ago

moved chromerdriver to the parent folder where Anaconda is downloaded and got this result now:

Starting ChromeDriver 85.0.4183.83 (94abc2237ae0c9a4cb5f035431c8adfb94324633-refs/branch-heads/4183@{#1658}) on port 9515 Only local connections are allowed. Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe. [1598556547.109][SEVERE]: bind() returned an error: Only one usage of each socket address (protocol/network address/port) is normally permitted. (0x2740) IPv6 port not available. Exiting...

davidteather commented 4 years ago

You should be including the script in the system path not the script path not a specific directory

demalem commented 4 years ago

Same error, I put chromedriver in C:\Users\emela and pointed all my scripts their as well.

davidteather commented 4 years ago

Here's an article on how to add to system path

demalem commented 4 years ago

Great thanks, I added it to the PATH variable. Here is a screenshot: image

Restarted kernel, and same error. I also tried running code from the Chromedriver homepage: https://sites.google.com/a/chromium.org/chromedriver/getting-started and ran into issues as well. I'm assuming I'm not correctly including chromedriver in the PATH or pointing to it accurately.

edenhikri commented 4 years ago

I have tried all of these resolutions and nothing seems to work. I am not in a country in which TikTok is banned. I have also tried running it with debug mode enabled api = TikTokApi(debug=True) however the issue still occurs. After printing 20 users stats, it gives me the error. It seems as though it gets stuck.

It should print the stats of the last 10 videos for each user that is over 1 million followers, and it does so. However, I get an error after it has printed 20 user's stats.

The error:

Traceback (most recent call last):
  File "snowball.py", line 24, in <module>
    tiktok = api.getUser(accounts)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/TikTokApi/tiktok.py", line 723, in getUser
    return self.getData(b, proxy=proxy)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/TikTokApi/tiktok.py", line 71, in getData
    query = {'verifyFp': b.verifyFp, 'did': b.did, '_signature': b.signature}
AttributeError: 'browser' object has no attribute 'verifyFp'

my code script (snowball.py)

from TikTokApi import TikTokApi

api = TikTokApi()

# file_data is the list of 150 tiktok users accounts) 

for accounts in file_data:
    tiktok = api.getUser(accounts)
    name = (tiktok['userInfo']['user']['uniqueId'])
    followers = (tiktok['userInfo']['stats']['followerCount'])

    if followers > 1000000:
        user_videos = api.byUsername(name, count=10)

        for video in user_videos:
            stats = (video['stats'])
            print(stats, name)

Also, if it helps, when I type in chromedriver into my macOS terminal... I get this:

Starting ChromeDriver X.X.X.X () on port 9515
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.

My internet connection is rather fast as well.

davidteather commented 4 years ago

@edenhikri does #246 solve your issue?

edenhikri commented 4 years ago

No, unfortunately it does not.

I have tried adding in 'dumpio': True to the launch options. However, the issue still persists.

edenhikri commented 4 years ago

This may help you as I have seen you request this on other similar issues. When I run:

from pyppeteer.launcher import Launcher
print(' '.join(Launcher().cmd))

I get this:

/Users/edenhikri/Library/Application Support/pyppeteer/local-chromium/588429/chrome-mac/Chromium.app/Contents/MacOS/Chromium --disable-background-networking --disable-background-timer-throttling --disable-breakpad --disable-browser-side-navigation --disable-client-side-phishing-detection --disable-default-apps --disable-dev-shm-usage --disable-extensions --disable-features=site-per-process --disable-hang-monitor --disable-popup-blocking --disable-prompt-on-repost --disable-sync --disable-translate --metrics-recording-only --no-first-run --safebrowsing-disable-auto-update --enable-automation --password-store=basic --use-mock-keychain --headless --hide-scrollbars --mute-audio about:blank --remote-debugging-port=51908 --user-data-dir=/Users/edenhikri/Library/Application Support/pyppeteer/.dev_profile/tmpi4lv6pb2
fastandslow007 commented 4 years ago

seems like you have too many request and then get blocked by tiktok server. have you try using proxy?

edenhikri commented 4 years ago

I am not sure if this is the issue... sometimes it works and does all the accounts, sometimes it gets stuck on the error... @fastandslow007

fastandslow007 commented 4 years ago

First, try to debug:

..
TikTokApi(debug=True)
..

Then enable dumpio on launch:

<yourenv>/lib/python3.6/site-packages/pyppeteer/launcher.py:
..
 81         self.dumpio = options.get('dumpio', True)
..

Run your script and notice the error. In my case, I got this error:

...
Class initialized
<xx>/local-chromium/588429/chrome-linux/chrome: error while loading shared libraries: libXss.so.1: cannot open shared object file: No such file or directory
The following error occurred, but it was ignored.
'browser' object has no attribute 'timezone_name'
<xx>/.local/share/pyppeteer/local-chromium/588429/chrome-linux/chrome: error while loading shared libraries: libXss.so.1: cannot open shared object file: No such file or directory
...
[ERROR]   ERROR-2 'browser' object has no attribute 'verifyFp'
...

Try to fix missing libXss.so.1 by installing this (I use Ubuntu):

$ apt-get install libxss1

Then the problem is fixed.

Thanks.

edenhikri commented 4 years ago

I have tried this...

I first enabled debug mode

api = TikTokApi(debug=True)

then I went into /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pyppeteer/launcher.py and changed line 81:

self.dumpio = options.get('dumpio', True)

then I ran snowball.py (my script)

It ran everything properly until it got stuck and brought up the same error:

...
DevTools listening on ws://127.0.0.1:53029/devtools/browser/28433110-68c9-4304-875e-5494698a533d
[0916/130613.905933:INFO:CONSOLE(1)] "%c", source:  (1)
Traceback (most recent call last):
  File "snowball.py", line 22, in <module>
    tiktok = api.getUser(accounts, proxy=None)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/TikTokApi/tiktok.py", line 723, in getUser
    return self.getData(b, proxy=proxy)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/TikTokApi/tiktok.py", line 71, in getData
    query = {'verifyFp': b.verifyFp, 'did': b.did, '_signature': b.signature}
AttributeError: 'browser' object has no attribute 'verifyFp'
fastandslow007 commented 4 years ago

Is it okay if you share the full log from the start?

edenhikri commented 4 years ago

This is what happens when I run snowball.py (python3 snowball.py) with debug mode set to True and dumpio enabled on launch:

(as it is lengthy I have put it in this link for you to view)

https://pastr.io/view/tuOfEKsXxly

I'm really not sure what the issue could be...

edenhikri commented 4 years ago

I discovered the issue may have been with google-api-core interfering with requests.

I simple fixed it by:

pip3 uninstall requests

then:

pip3 uninstall google-api-core

finally:

pip3 install requests
edenhikri commented 4 years ago

Unfortunately, this did not actually fix the issue. It seemed to only have fixed the issue for a few hours... I am really not sure what is causing this issue. Can you please help me out @davidteather

davidteather commented 4 years ago

I’ve got no clue what your issue is. You could try to make a VM for a fresh start. The .travis.yml file has specific setup commands

edenhikri commented 4 years ago

Those instructions are linux specific... are you able to provide Mac instructions? @davidteather

edenhikri commented 4 years ago

I am really unsure what the issue may be... I have tried installing a new virtual environment, running it with debug mode set to True and dumpio enabled on launch. Nothing seems to work. I would love to use this program however it does not work for me

davidteather commented 4 years ago

@edenhikri might be an issue with your actual IP address might be blocked by TikTok. When I used heroku it didn't like how they had their IPs setup. When I had a dedicated IP on a AWS ec2 instance it worked. You might want to try making the requests over a proxy (most publically available free ones probably wont work)

edenhikri commented 4 years ago

@davidteather So I tried using a private proxy that I bought. It is based in United States and I ran the script in debug mode in a virtual environment with the proxy and I still got the same error: (I even tried running with dumpio set to True on launch and got the same error)

  File "pinpoint.py", line 164, in pullandsort
    description()
  File "pinpoint.py", line 80, in description
    tiktok = api.getUser(name, proxy=myproxy)
  File "/Users/edenhikri/Desktop/ANYMERCH/programming/pinpoint/venv/lib/python3.8/site-packages/TikTokApi/tiktok.py", line 723, in getUser
    return self.getData(b, proxy=proxy)
  File "/Users/edenhikri/Desktop/ANYMERCH/programming/pinpoint/venv/lib/python3.8/site-packages/TikTokApi/tiktok.py", line 71, in getData
    query = {'verifyFp': b.verifyFp, 'did': b.did, '_signature': b.signature}
AttributeError: 'browser' object has no attribute 'verifyFp'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "pinpoint.py", line 231, in <module>
    startup()
  File "pinpoint.py", line 227, in startup
    locate()
  File "pinpoint.py", line 49, in locate
    sort()
  File "pinpoint.py", line 71, in sort
    pullandsort()
  File "pinpoint.py", line 167, in pullandsort
    description()
  File "pinpoint.py", line 80, in description
    tiktok = api.getUser(name, proxy=myproxy)
  File "/Users/edenhikri/Desktop/ANYMERCH/programming/pinpoint/venv/lib/python3.8/site-packages/TikTokApi/tiktok.py", line 723, in getUser
    return self.getData(b, proxy=proxy)
  File "/Users/edenhikri/Desktop/ANYMERCH/programming/pinpoint/venv/lib/python3.8/site-packages/TikTokApi/tiktok.py", line 71, in getData
    query = {'verifyFp': b.verifyFp, 'did': b.did, '_signature': b.signature}
AttributeError: 'browser' object has no attribute 'verifyFp'
edenhikri commented 4 years ago

Is there anything else I can try? @davidteather

fastandslow007 commented 4 years ago

Hi,

Sorry to jump in again.

“ OSError: [Errno 24] Too many open files”

Have you try to increase open files via sysctl.conf or limits.conf or ulimit?

On Mon, 21 Sep 2020 at 06.55 edenhikri notifications@github.com wrote:

Is there anything else I can try? @davidteather https://github.com/davidteather

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/davidteather/TikTok-Api/issues/237#issuecomment-695853072, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALMYDB6P5YKCBNV7SAT6YW3SG2I6LANCNFSM4QK74G2A .

fastandslow007 commented 4 years ago

might depend on your osx version as well. but lauchd and ulimit should do.

I found by simply googling: "macos too many open files". https://superuser.com/questions/830149/os-x-yosemite-too-many-files-open https://medium.com/mindful-technology/too-many-open-files-limit-ulimit-on-mac-os-x-add0f1bfddde

On Tue, Sep 22, 2020 at 8:30 AM edenhikri notifications@github.com wrote:

@fastandslow007 https://github.com/fastandslow007 I am on a Mac... where are these files located?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/davidteather/TikTok-Api/issues/237#issuecomment-696465137, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALMYDBZKNSNE5IGHZRF7GQDSG742LANCNFSM4QK74G2A .

AlexB51 commented 4 years ago

If this is still an issue for you, I had the same problem. I added the following and it resolved the issue with set_async:

from TikTokApi.browser import set_async set_async()

Good luck, and let me know!

lo-fo commented 4 years ago

same issue here.

virtualenv -p python3.8 tiktok_api_test cd tiktok_api_test source bin/activate pip install TikTokApi

I dump the example code into test.py

python test.py

here is what i get

[W:pyppeteer.chromium_downloader] start chromium download. Download may take a few minutes. [W:pyppeteer.chromium_downloader] start chromium download. Download may take a few minutes. Traceback (most recent call last): File "test.py", line 7, in <module> trending = api.trending(count=results) File "/private/tmp/tiktok_api_test/lib/python3.8/site-packages/TikTokApi/tiktok.py", line 154, in trending res = self.getData(b, proxy=proxy) File "/private/tmp/tiktok_api_test/lib/python3.8/site-packages/TikTokApi/tiktok.py", line 72, in getData query = {'verifyFp': b.verifyFp, 'did': b.did, '_signature': b.signature} AttributeError: 'browser' object has no attribute 'verifyFp'

running chromedriver in the terminal outputs this

Starting ChromeDriver 85.0.4183.87 (cd6713ebf92fa1cacc0f1a598df280093af0c5d7-refs/branch-heads/4183@{#1689}) on port 9515 Only local connections are allowed. Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe. ChromeDriver was started successfully.

Danielohayon commented 4 years ago

If this is still an issue for you, I had the same problem. I added the following and it resolved the issue with set_async:

from TikTokApi.browser import set_async set_async()

Good luck, and let me know!

I had the same problem and this solved it. Thanks!

vasemkin commented 4 years ago

i encountered the same issue. simply running pyppeteer-install was the solution for me.

hanqingguo commented 4 years ago

If this is still an issue for you, I had the same problem. I added the following and it resolved the issue with set_async: from TikTokApi.browser import set_async set_async() Good luck, and let me know!

I had the same problem and this solved it. Thanks!

Same issue and solved by this!

Incher25 commented 4 years ago

If this is still an issue for you, I had the same problem. I added the following and it resolved the issue with set_async:

from TikTokApi.browser import set_async set_async()

Good luck, and let me know!

I have the same issue with "verifyFp" but after adding set_async() I just have anorher error:

Error in atexit._run_exitfuncs: Traceback (most recent call last): File "/usr/lib/python3.6/asyncio/base_events.py", line 454, in run_until_complete self.run_forever() File "/usr/lib/python3.6/asyncio/base_events.py", line 408, in run_forever raise RuntimeError('This event loop is already running') RuntimeError: This event loop is already running

WinkyDev commented 4 years ago

If this is still an issue for you, I had the same problem. I added the following and it resolved the issue with set_async: from TikTokApi.browser import set_async set_async() Good luck, and let me know!

I have the same issue with "verifyFp" but after adding set_async() I just have anorher error:

Error in atexit._run_exitfuncs: Traceback (most recent call last): File "/usr/lib/python3.6/asyncio/base_events.py", line 454, in run_until_complete self.run_forever() File "/usr/lib/python3.6/asyncio/base_events.py", line 408, in run_forever raise RuntimeError('This event loop is already running') RuntimeError: This event loop is already running

Same error here

gopida commented 4 years ago

I had the same issue after deploying it to my raspberry pi, whereas it is working perfectly in windows. Looks like the issue is with the pyppeteer browser. Did not investigate it completely, but the below fixed the issue.

Fix

pass the below argument while creating TikTokApi() object executablePath = '/usr/bin/chromium-browser'

Command to find the path - "whereis chromium-browser"

Alternative: Or directly hardcode the browser path in site-packages/TikTokApi/browser.py (wouldn't recommend, but can give a try if the 1st doesn't work) self.executablePath = '/usr/bin/chromium-browser'

Hopefully, this works in Linux as well.

izuzyun commented 4 years ago

I've tried all of your recommendations, but the problem remained unresolved Here's the code with all libraries: `from TikTokApi import TikTokApi from TikTokApi.browser import set_async set_async() api = TikTokApi()

results = 10

trending = api.trending(count=results)

for tiktok in trending:

Prints the text of the tiktok

print(tiktok['desc'])

print(len(trending)) And here's some errors: [W:pyppeteer.chromium_downloader] start chromium download. Download may take a few minutes. Traceback (most recent call last): ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1108)

During handling of the above exception, another exception occurred: ` How can I solve it on MacOS?

gopida commented 4 years ago

ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] The issue you are facing seem to be different than the one discussed in this thread. See this for possible solution for ssl issue.

davidteather commented 3 years ago

Since I've migrated the API to playwright information here may be outdated for TikTokApi >= 3.7.0 if anyone has the same issues on 3.7.0 or greater please open a new issue.

viniciusao commented 3 years ago

What happens when you type the following command into your terminal

chromedriver

I was getting an error that TikTokApi didn't have an attribute (width). When I saw your post, it enlighted me. I didn't know I should had started chromedriver x)! Thanks, mate.