davidteather / TikTok-Api

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

[BUG] #35

Closed Lem0nTree closed 4 years ago

Lem0nTree commented 4 years ago

Describe the bug

DevTools listening on ws://127.0.0.1:55641/devtools/browser/414bc91b-8f0a-4365-98a8-0ffb1521f769
Traceback (most recent call last):
  File ".\test.py", line 13, in <module>
    result = api.search_by_hashtag(trending_tags[0])
IndexError: list index out of range

The buggy code

from TikTokApi import TikTokapi

# Starts The Api Class
api = TikTokapi("browsermob-proxy/bin/browsermob-proxy")

# The Number of trending TikToks you want to be displayed
results = 10

# Gets trending hashtags
trending_tags = api.get_trending_hashtags()

# Searches for the top trending hashtag of TikTok
result = api.search_by_hashtag(trending_tags[0])

for tiktok in result:
    # Prints the text of the tiktok
    print(tiktok['itemInfos']['text'])

print(len(result))

Expected behavior

Updated to the latest version of TikTokApi, used an example to test them, but seems to be stuck on loading tiktok feed inside chrome browser

Screenshots

https://snipboard.io/GtqST7.jpg

Desktop (please complete the following information):

Additional context

Add any other context about the problem here.

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

Issue-Label Bot is automatically applying the label bug to this issue, with a confidence of 1.00. 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

I forgot to change the example files with the new update. There is no longer a trending_tags() method as they are not displayed on TikTok's main page. Below is code that should work.

from TikTokApi import TikTokapi

# Starts The Api Class
api = TikTokapi("browsermob-proxy/bin/browsermob-proxy")

# The Number of trending TikToks you want to be displayed
results = 10

# Searches for the top trending hashtag of TikTok
result = api.search_by_hashtag("funny")

for tiktok in result:
    # Prints the text of the tiktok
    print(tiktok['itemInfos']['text'])

print(len(result))
api.quit_browser()

I will change that example file.

Lem0nTree commented 4 years ago

If i use your code it works well, if i put your code on my previous working code it gives me something wrong without any error :s Can you help me, i really don't understand what is wrong with my code that worked well with your previous api :(

davidteather commented 4 years ago

@theparcel What part of your code doesn't work? Since you added me on your repository it seems like the downloader.py file works fine at least for me.

Edit: I'll open a issue in your repository instead of on here