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] - EmptyResponseException when using user.info and video.info #1213

Open
Ksenon07147 opened this issue Jan 13, 2025 · 0 comments
Open
Labels
bug Something isn't working

Comments

@Ksenon07147
Copy link

Ksenon07147 commented Jan 13, 2025

Describe the bug

Since around 23 December 2024, the Tiktok-API library can't get the post info from tiktok.com. It keeps showing me the Empty Response exception when I calling user.info and video.info.

The buggy code

  1. user.info code snippet
# Info: this code running inside a class called TikTokScrapper
# self.get_ms_token() gets a random ms_token saved inside a text file that i copy paste from chrome browser that accesing tiktok.com

async with TikTokApi() as profile_api:
    await profile_api.create_sessions(headless=False, ms_tokens=[self.get_ms_token()], num_sessions=1, sleep_after=3)
    time.sleep(1)
    user = profile_api.user(self.name)
    user_data = await user.info()
    video_data = []
    async for video in user.videos(count=self.num):
        video_data.append(video.as_dict)
  1. video.info code snippet
# Info: this code running inside a class called TikTokScrapper
# self.get_ms_token() gets a random ms_token saved inside a text file that i copy paste from chrome browser that accesing tiktok.com

async with TikTokApi() as video_api:
    await video_api.create_sessions(headless=False, ms_tokens=[self.get_ms_token()], num_sessions=1, sleep_after=3)
    # get video info
    video = video_api.video(url=url)
    video_info = await video.info()

Expected behavior

  1. user.info code
  • User's profile information json will be get and stored in user_data variable for next step, getting video's information for process.
  1. video.info code
  • Video information will store in video_info and prepared to process.

Error Trace (if any)

  1. user.info code
DATETIME:2025-01-13 09:41:30 : TT_scrape | TikTokAPI error  err = None -> TikTok returned an empty response | traceback=Traceback (most recent call last):
  File "C:\XXX\scrapper.py", line 956, in TT_scrape
    user_data = await user.info()
                ^^^^^^^^^^^^^^^^^
  File "C:\XXX\env\Lib\site-packages\TikTokApi\api\user.py", line 76, in info
    resp = await self.parent.make_request(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\XXX\env\Lib\site-packages\TikTokApi\tiktok.py", line 467, in make_request
    raise EmptyResponseException(result, "TikTok returned an empty response")
TikTokApi.exceptions.EmptyResponseException: None -> TikTok returned an empty response
  1. video.info code
API Error - None -> TikTok returned an empty response

Desktop:

  • OS: Windows Server 2022 Datacenter Azure Edition
  • Python Version: 3.11.8
  • TikTokApi Version: 6.5.2
  • Playwright Version: 1.30.0

Additional context

  1. The proxy has been used and get timeout error. (the await page.goto(url) disabled timeout as suggestion in [BUG] - playwright._impl._api_types.TimeoutError: Timeout 30000ms exceeded. #1054 (comment) gets the connection closed exception)
  • Code Snippet:
async with TikTokApi() as profile_api:
    await profile_api.create_sessions(headless=False, ms_tokens=[self.get_ms_token()], num_sessions=1, sleep_after=3, proxies=[self.get_proxy_dict()])
    
# proxy dict function
def get_proxy_dict(self):
    '''
    str >> hostname:port:login:passport
    {
        "server": "http://myproxy.com:3128",
        "username": "usr",
        "password": "pwd"
    }
    '''
    
    
    proxy_list = (self.proxy_string).split(":")
    proxy_dict = {
        "server": f"http://{proxy_list[0]}:{proxy_list[1]}",
        "username": proxy_list[2],
        "password": proxy_list[3]
    }
    return proxy_dict
  • Error
API Error - Cannot read properties of undefined (reading 'text')
API Error - Timeout 30000ms exceeded.
=========================== logs ===========================
navigating to "https://www.tiktok.com/", waiting until "load"
============================================================
  1. Both API call returns same error.
  2. The video.info work when you click a video in Playwright browser to solve captcha manually. ( user.info doesn't work even you solve captcha manually)
@Ksenon07147 Ksenon07147 added the bug Something isn't working label Jan 13, 2025
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

1 participant