Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] - Failed to run even hashtag_example i added ms_token #1162

Open
vagvalas opened this issue Jun 17, 2024 · 5 comments
Open

[BUG] - Failed to run even hashtag_example i added ms_token #1162

vagvalas opened this issue Jun 17, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@vagvalas
Copy link

I'm unable to run even the examples with an added ms_token, I'm not sure if i had done everything right but i cant seem to understand exactly if i had also to add a cookie, or how do i get a cookie except from ms_token.
I think the line ms_token, None i had filled correctly.

I modified the example:

from TikTokApi import TikTokApi
import asyncio
import os

ms_token = os.environ.get("sySiUDTlgtCc9mZpdOuYuP1stjvSP8mgMSG3jQEDXBK6X86EuOqzLjjFAs8KMWVrg1G_8C7uTxm4We4_oDyjZidveAfd7lb5-DFhGFkaqsi8tRFnV7dYiIaPsxr0SFt6v-d6RSNE3JsNFqaYS8w=", None)  # set your own ms_token


async def get_hashtag_videos():
    async with TikTokApi() as api:
        await api.create_sessions(ms_tokens=[ms_token], num_sessions=1, sleep_after=3)
        tag = api.hashtag(name="coldplayathens")
        async for video in tag.videos(count=150):
            print(video)
            print(video.as_dict)


if __name__ == "__main__":
    asyncio.run(get_hashtag_videos())

Error Trace (if any)

Put the error trace below if there's any error thrown.

File "/usr/local/Cellar/python@3.10/3.10.14/Frameworks/Python.framework/Versions/3.10/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/local/Cellar/python@3.10/3.10.14/Frameworks/Python.framework/Versions/3.10/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/Users/vaggosval/Desktop/toktik/TikTok-Api/examples/hashtag_example.py", line 18, in <module>
    asyncio.run(get_hashtag_videos())
  File "/usr/local/Cellar/python@3.10/3.10.14/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/usr/local/Cellar/python@3.10/3.10.14/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
    return future.result()
  File "/Users/vaggosval/Desktop/toktik/TikTok-Api/examples/hashtag_example.py", line 12, in get_hashtag_videos
    async for video in tag.videos(count=150):
  File "/Users/vaggosval/Desktop/toktik/TikTok-Api/TikTokApi/api/hashtag.py", line 118, in videos
    resp = await self.parent.make_request(
  File "/Users/vaggosval/Desktop/toktik/TikTok-Api/TikTokApi/tiktok.py", line 441, in make_request
    raise EmptyResponseException(result, "TikTok returned an empty response")
TikTokApi.exceptions.EmptyResponseException: None -> TikTok returned an empty response

Desktop (please complete the following information):

  • OS: [e.g. macOS 11.7.10]
  • TikTokApi Version [e.g. 6.4.0] - if out of date upgrade before posting an issue

Additional context

Add any other context about the problem here.

@vagvalas vagvalas added the bug Something isn't working label Jun 17, 2024
@jagl16
Copy link

jagl16 commented Jun 19, 2024

Seems like related to #1090

Easiest workaround for me on mac was to set headless=False for now.

@vagvalas
Copy link
Author

I finally , and also using this help, and chatGPT finally made to make a script to fetch and port to yt_dlp and download all videos i need.
BUT , as i undestand it only fetches till the public ones.. i mean, the hashtag has 2,000 videos, and even if im logged in and not logged in i can see through my browser 50 videos (45 sometimes)
and the TikTok-Api it COMPLETES and finishes the script on 45 videos..

Is there any workaround on this? how to fetch more? as logged in?

@zhangzyg
Copy link

zhangzyg commented Jul 2, 2024

@jagl16 @vagvalas I faced the same issue in a sudden even when I switch headless=False


API sends is like: https://www.tiktok.com/api/challenge/item_list

but still receive empty response, is there some anti-scrape enhancement from tik-tok?

@jagl16
Copy link

jagl16 commented Jul 3, 2024

@zhangzyg I haven't tried it again in a few weeks, but wouldn't be surprised if tiktok did implement new anti scraping changes.

@florifull
Copy link

Any updates here?

@vagvalas would you be willing you share your new script for scraping by hashtag?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants