davidteather / TikTok-Api

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

[BUG] - 'browser' object has no attribute 'signature' #182

Closed kbyatnal closed 4 years ago

kbyatnal commented 4 years ago

Describe the bug

I think this may be a similar issue as the 'verifyFp' problem. It happens occasionally, despite my proxy server being in the US.

app/worker.14 [2020-07-14 16:38:17,509: WARNING/ForkPoolWorker-1] 'browser' object has no attribute 'signature'
app/worker.14     save_tiktoks_for_user(record_id, username)
app/worker.14   File "/app/tasks.py", line 29
app/worker.14     tiktoks = api.byUsername(tiktok_username, count=250)
app/worker.14   File "/app/.heroku/python/lib/python3.7/site-packages/TikTokApi/tiktok.py", line 147, in byUsername
app/worker.14     return self.getUser(username, language, proxy=proxy)['userInfo']['user']
app/worker.14     "&_signature=" + b.signature
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.99. Please mark this comment with :thumbsup: or :thumbsdown: to give our bot feedback!

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

davidteather commented 4 years ago

Are you using a free proxy? I'd imagine TikTok has denied requests from known free proxies.

Could you run this again and give the result while enabling debug mode? api = TikTokApi(debug=True)

kbyatnal commented 4 years ago

Nope, using a paid proxy.

app/worker.3 [2020-07-14 17:21:31,723: WARNING/ForkPoolWorker-1] 'browser' object has no attribute 'signature'
app/worker.3 [2020-07-14 17:21:31,724: WARNING/ForkPoolWorker-1] Traceback (most recent call last):
app/worker.3   File "/app/tasks.py", line 134, in process_user
app/worker.3     save_tiktoks_for_user(record_id, username)
app/worker.3   File "/app/tasks.py", line 29, in save_tiktoks_for_user
app/worker.3     tiktoks = api.byUsername(tiktok_username, count=250)
app/worker.3   File "/app/.heroku/python/lib/python3.7/site-packages/TikTokApi/tiktok.py", line 147, in byUsername
app/worker.3     data = self.getUserObject(username, proxy=proxy)
app/worker.3   File "/app/.heroku/python/lib/python3.7/site-packages/TikTokApi/tiktok.py", line 338, in getUserObject
app/worker.3     return self.getUser(username, language, proxy=proxy)['userInfo']['user']
app/worker.3   File "/app/.heroku/python/lib/python3.7/site-packages/TikTokApi/tiktok.py", line 347, in getUser
app/worker.3     return self.getData(api_url, b, proxy=proxy)
app/worker.3   File "/app/.heroku/python/lib/python3.7/site-packages/TikTokApi/tiktok.py", line 30, in getData
app/worker.3     "&_signature=" + b.signature
app/worker.3 AttributeError: 'browser' object has no attribute 'signature'
kbyatnal commented 4 years ago

I'm wondering if it could be related to the latest package update. Before, I would run into this issue 10% of the time and a simple retry would fix.

I updated the package this morning and now, I'm running into this issue 100% of the time - I can't get a single call to succeed (with no changes in the IPs being used).

davidteather commented 4 years ago

I'll be releasing an update that hopefully fixes this later today.

kbyatnal commented 4 years ago

Thanks! Just in case this is helpful - this is even happening when I try calling the API locally (without a proxy) from my residential IP. I can access TikTok just fine otherwise.

davidteather commented 4 years ago

Alright I released a new version does this one seem to help? It's strange it doesn't work on your residential ip.

kbyatnal commented 4 years ago

Might be an issue with formatting one of the parameters

Traceback (most recent call last):
  File "tasks.py", line 134, in process_user
    save_tiktoks_for_user(record_id, username)
  File "tasks.py", line 29, in save_tiktoks_for_user
    tiktoks = api.byUsername(tiktok_username, count=250)
  File "/Users/kb/.local/share/virtualenvs/fyp-rip-L7VQU4Zi/lib/python3.7/site-packages/TikTokApi/tiktok.py", line 148, in byUsername
    data = self.getUserObject(username, proxy=proxy)
  File "/Users/kb/.local/share/virtualenvs/fyp-rip-L7VQU4Zi/lib/python3.7/site-packages/TikTokApi/tiktok.py", line 339, in getUserObject
    return self.getUser(username, language, proxy=proxy)['userInfo']['user']
  File "/Users/kb/.local/share/virtualenvs/fyp-rip-L7VQU4Zi/lib/python3.7/site-packages/TikTokApi/tiktok.py", line 347, in getUser
    b = browser(api_url, proxy=proxy)
  File "/Users/kb/.local/share/virtualenvs/fyp-rip-L7VQU4Zi/lib/python3.7/site-packages/TikTokApi/browser.py", line 57, in __init__
    loop.run_until_complete(self.start())
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/asyncio/base_events.py", line 584, in run_until_complete
    return future.result()
  File "/Users/kb/.local/share/virtualenvs/fyp-rip-L7VQU4Zi/lib/python3.7/site-packages/TikTokApi/browser.py", line 99, in start
    }''')
  File "/Users/kb/.local/share/virtualenvs/fyp-rip-L7VQU4Zi/lib/python3.7/site-packages/pyppeteer/page.py", line 1184, in evaluate
    return await frame.evaluate(pageFunction, *args, force_expr=force_expr)
  File "/Users/kb/.local/share/virtualenvs/fyp-rip-L7VQU4Zi/lib/python3.7/site-packages/pyppeteer/frame_manager.py", line 309, in evaluate
    pageFunction, *args, force_expr=force_expr)
  File "/Users/kb/.local/share/virtualenvs/fyp-rip-L7VQU4Zi/lib/python3.7/site-packages/pyppeteer/execution_context.py", line 54, in evaluate
    pageFunction, *args, force_expr=force_expr)
  File "/Users/kb/.local/share/virtualenvs/fyp-rip-L7VQU4Zi/lib/python3.7/site-packages/pyppeteer/execution_context.py", line 113, in evaluateHandle
    helper.getExceptionMessage(exceptionDetails)))
pyppeteer.errors.ElementHandleError: Evaluation failed: SyntaxError: Invalid or unexpected token
davidteather commented 4 years ago

Are you able to open this link without errors? That's the only real change I've made to 2 versions ago.

kbyatnal commented 4 years ago

Yup, no issue with opening that link. Will keep digging...

hoylemd commented 4 years ago

I'm running into this now - it happens consistently every time I try to retrieve something:

from TikTokApi import TikTokApi
api = TikTokApi()

results = 10

trending = api.trending(count=results)

produces:

Class initialized
[W:pyppeteer.chromium_downloader] start chromium download.
Download may take a few minutes.
The following error occurred, but it was ignored.
'browser' object has no attribute 'timezone_name'
[W:pyppeteer.chromium_downloader] start chromium download.
Download may take a few minutes.
Traceback (most recent call last):
  File "tt_scratch.py", line 7, in <module>
    trending = api.trending(count=results)
  File "/Users/michaelhoyle/miniconda3/envs/pixacollect2/lib/python3.8/site-packages/TikTokApi/tiktok.py", line 114, in trending
    res = self.getData(api_url, b, proxy=proxy)
  File "/Users/michaelhoyle/miniconda3/envs/pixacollect2/lib/python3.8/site-packages/TikTokApi/tiktok.py", line 55, in getData
    "&verifyFp=" + b.verifyFp + \
AttributeError: 'browser' object has no attribute 'verifyFp'

I tried adding a default fields to the browser class for verifyFp and signature, but then I just get empty responses (which fail JSON parsing, raising simplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

hoylemd commented 4 years ago

Following https://github.com/davidteather/TikTok-Api/issues/178#issuecomment-657244793 fixed it.

@davidteather Might be worth adding that to the installation instructions. Seems to be required now

davidteather commented 4 years ago

Ok I'll close this issue then. @hoylemd it's not usually required. It automatically installs on the test servers for me

hoylemd commented 4 years ago

Maybe it's just a mac thing? Either way, there seem to a lot of issues posted where that's the solution. Might save you and other some time to stick it in the readme. Just a suggestion :)