Ejemplo n.º 1
0
def test_user():
    api = TikTokApi()

    assert api.getUser(
        'charlidamelio')['userInfo']['user']['uniqueId'] == 'charlidamelio'
    sleep(1)
    assert api.getUserObject('charlidamelio')['uniqueId'] == 'charlidamelio'
    sleep(1)
    assert abs(
        len(
            api.userPosts(
                userID="5058536",
                secUID=
                "MS4wLjABAAAAoRsCq3Yj6BtSKBCQ4rf3WQYxIaxe5VetwJfYzW_U5K8",
                count=5)) - 5) <= 1
    sleep(1)
    assert abs(
        len(
            api.userPosts(
                userID="5058536",
                secUID=
                "MS4wLjABAAAAoRsCq3Yj6BtSKBCQ4rf3WQYxIaxe5VetwJfYzW_U5K8",
                count=10)) - 10) <= 1
    sleep(1)
    assert abs(
        len(
            api.userPosts(
                userID="5058536",
                secUID=
                "MS4wLjABAAAAoRsCq3Yj6BtSKBCQ4rf3WQYxIaxe5VetwJfYzW_U5K8",
                count=30)) - 30) <= 1

    # assert len(api.userLikedbyUsername(username="", count=30)) == 30


# api = TikTokApi()
# t = api.getUser('charlidamelio')
# print(t)
# print(t['userInfo']['user'])
Ejemplo n.º 2
0
def test_user_object():
    api = TikTokApi()
    assert len(api.getUserObject('therock')) > 0
Ejemplo n.º 3
0
# count and list all of the posts for a given user with the pager
total = 0

pager = api.getUserPager(username, page_size=count)

for page in pager:
    printPage(page)
    total += len(page)

print('{} has {} posts'.format(username, total))
all_posts = total

# List all of the posts for a given user after a certain date

APR_24 = 1587757438000  # 2020-04-24 15:43:58 to be precise. Must be ms-precision UNIX timestamp
user = api.getUserObject(username)
page = api.userPage(user['id'], user['secUid'], page_size=30, after=APR_24)

printPage(page['items'])
new_posts = len(page['items'])
print('{} has {} posts after {}'.format(username, new_posts, APR_24))

# Count and list all of the posts before a certain date for a given user with the pager

total = 0
pager = api.getUserPager(username, page_size=count, before=APR_24)

for page in pager:
    printPage(page)
    total += len(page)