def test_hashtag(): api = TikTokapi("browsermob-proxy/bin/browsermob-proxy", headless=False) res = api.search_by_hashtag("funny") api.quit_browser() assert len(res) == 10 assert checkDupes(res) == 0
def test_get_video_by_url(): api = TikTokapi("browsermob-proxy/bin/browsermob-proxy", headless=False) bytesV = api.get_Video_By_Url( "https://www.tiktok.com/@bts_official_bighit/video/6741282343362759938?langCountry=en", return_bytes=1) assert type(bytesV) == type(bytes()) api.quit_browser()
def test_sound(): api = TikTokapi("browsermob-proxy/bin/browsermob-proxy", headless=True) assert len(api.search_by_sound("https://www.tiktok.com/music/original-sound-6742171751955843846", count=5)) == 5 assert len(api.search_by_sound("https://www.tiktok.com/music/original-sound-6742171751955843846", count=10)) == 10 assert len(api.search_by_sound("https://www.tiktok.com/music/original-sound-6742171751955843846", count=30)) == 30 api.quit_browser()
def getUser(results): api = TikTokapi("browsermob-proxy/bin/browsermob-proxy", headless=True) result = api.userPosts( "5058536", "MS4wLjABAAAAoRsCq3Yj6BtSKBCQ4rf3WQYxIaxe5VetwJfYzW_U5K8", count=results) api.quit_browser() return len(result)
def test_hashtag(): api = TikTokapi("browsermob-proxy/bin/browsermob-proxy", headless=True) res = api.search_by_hashtag("funny", count=10) assert len(res) == 10 assert checkDupes(res) == 0 res = api.search_by_hashtag("funny", count=50) assert len(res) == 50 assert checkDupes(res) == 0
def test_user(): api = TikTokapi("browsermob-proxy/bin/browsermob-proxy", headless=True) assert len( api.userPosts( id="5058536", secUid="MS4wLjABAAAAoRsCq3Yj6BtSKBCQ4rf3WQYxIaxe5VetwJfYzW_U5K8", count=5)) == 5 assert len( api.userPosts( id="5058536", secUid="MS4wLjABAAAAoRsCq3Yj6BtSKBCQ4rf3WQYxIaxe5VetwJfYzW_U5K8", count=10)) == 10 assert len( api.userPosts( id="5058536", secUid="MS4wLjABAAAAoRsCq3Yj6BtSKBCQ4rf3WQYxIaxe5VetwJfYzW_U5K8", count=30)) == 30 api.quit_browser()
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))
# NOTE: This python file cannot be run from the examples folder. # It MUST BE in the same directory as tiktok.py is located! # Yeah sorry, it's kind of annoying, but it's more organized this way. from TikTokApi import TikTokapi # Starts T api = TikTokapi("path/to/browsermob-proxy") # The Number of trending TikToks you want to be displayed results = 10 trending = api.trending(results) for tiktok in trending: # Prints the text of the tiktok print(tiktok['itemInfos']['text']) print(len(trending))
def getTrending(results): api = TikTokapi("browsermob-proxy/bin/browsermob-proxy", headless=True) trending = api.trending(results) return len(trending)
def getUser(results): api = TikTokapi("browsermob-proxy/bin/browsermob-proxy", headless=False) result = api.userPosts("jadenthekingsley", count=results) api.quit_browser() return len(result)
def test_trending(): api = TikTokapi("browsermob-proxy/bin/browsermob-proxy", headless=False) assert len(api.trending(5)) == 5 assert len(api.trending(10)) == 10 api.quit_browser()
def getUser(results): api = TikTokapi("browsermob-proxy/bin/browsermob-proxy", headless=True) result = api.userPosts("6718751032510759942", count=results) return len(result)
def test_get_trending_hashtag(): api = TikTokapi("browsermob-proxy/bin/browsermob-proxy", headless=True) assert len(api.get_trending_hashtags()) == 4
def test_extended_trending(): api = TikTokapi("browsermob-proxy/bin/browsermob-proxy", headless=True) assert len(api.trending(50)) == 50 assert len(api.trending(100)) == 100 api.quit_browser()
def test_trending(): api = TikTokapi("browsermob-proxy/bin/browsermob-proxy", headless=True) assert len(api.trending(5)) == 5 assert len(api.trending(10)) == 10 assert len(api.trending(20)) == 20