Skip to content

Commit 98ba02a

Browse files
committed
Add demo.py Ver Chg to V1.0.1
1 parent e462b9b commit 98ba02a

File tree

5 files changed

+86
-3
lines changed

5 files changed

+86
-3
lines changed

demo/demo.py

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
import asyncio
2+
import time
3+
4+
from tikhub.api import API
5+
6+
7+
async def async_test() -> None:
8+
# 异步测试/Async test
9+
10+
tiktok_url = 'https://www.tiktok.com/@evil0ctal/video/7156033831819037994'
11+
12+
tiktok_music_url = 'https://www.tiktok.com/music/original-sound-7128362040359488261'
13+
14+
douyin_url = 'https://www.douyin.com/video/7153585499477757192'
15+
16+
douyin_user_url = 'https://www.douyin.com/user/MS4wLjABAAAAaNJuvXC83kL5nhaZHubKdjsRJQovgz58wXzlLnJUsslG-Kb24TM1QJlf_2HMaUJk'
17+
18+
print("Test start...\n")
19+
start_time = time.time()
20+
21+
# 获取TikHub请求头/Get TikHub request header
22+
print("Running test : API.authenticate()")
23+
await api.authenticate()
24+
25+
# 获取TikHub用户信息/Get TikHub user information
26+
print("Running test : API.get_user_info()")
27+
await api.get_user_info()
28+
29+
print("\nRunning ALL TikTok methods test...\n")
30+
31+
# 获取单个视频数据/Get single video data
32+
print("Running test : API.get_tiktok_video_data()")
33+
await api.get_tiktok_video_data(tiktok_url)
34+
35+
# 获取获取用户主页的所有视频数据/Get all video data on the user's homepage
36+
print("Running test : API.get_tiktok_profile_videos()")
37+
aweme_list = await api.get_tiktok_profile_videos(tiktok_url, 20)
38+
print(f'Get {len(aweme_list)} videos from profile')
39+
40+
# 获取用户主页的所有点赞视频数据/Get all liked video data on the user's homepage
41+
print("Running test : API.get_tiktok_profile_liked_videos()")
42+
aweme_list = await api.get_tiktok_profile_liked_videos(tiktok_url, 20)
43+
print(f'Get {len(aweme_list)} liked videos from profile')
44+
45+
# 获取TikTok视频的所有评论数据/Get all comment data of TikTok video
46+
print("Running test : API.get_tiktok_video_comments()")
47+
comments_list = await api.get_tiktok_video_comments(tiktok_url, 20)
48+
print(f'Get {len(comments_list)} comments from video')
49+
50+
# 获取音乐页面上的所有(理论上能抓取到的)视频数据/Get all (theoretically) video data on the music page
51+
print("Running test : API.get_tiktok_music_videos()")
52+
aweme_list = await api.get_tiktok_music_videos(tiktok_music_url, 20)
53+
print(f'Get {len(aweme_list)} videos from music')
54+
55+
print("\nRunning ALL Douyin methods test...\n")
56+
57+
# 获取单个视频数据/Get single video data
58+
print("Running test : API.get_douyin_video_data()")
59+
await api.get_douyin_video_data(douyin_url)
60+
61+
# 获取获取用户主页的所有视频数据/Get all video data on the user's homepage
62+
print("Running test : API.get_douyin_profile_videos()")
63+
aweme_list = await api.get_douyin_profile_videos(douyin_user_url, 20)
64+
print(f'Get {len(aweme_list)} videos from profile')
65+
66+
# 获取用户主页的所有点赞视频数据/Get all liked video data on the user's homepage
67+
print("Running test : API.get_douyin_profile_liked_videos()")
68+
aweme_list = await api.get_douyin_profile_liked_videos(douyin_user_url, 20)
69+
print(f'Get {len(aweme_list)} liked videos from profile')
70+
71+
# 总耗时/Total time
72+
total_time = round(time.time() - start_time, 2)
73+
print("\nTest completed, total time: {}s".format(total_time))
74+
75+
76+
if __name__ == '__main__':
77+
api = API(
78+
username='test',
79+
password='test',
80+
proxy=None,
81+
)
82+
asyncio.run(async_test())

dist/tikhub-1.0.1-py3-none-any.whl

10.2 KB
Binary file not shown.

dist/tikhub-1.0.1.tar.gz

10.5 KB
Binary file not shown.

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
setuptools.setup(
1515
name='tikhub',
1616
author='TikHub.io',
17-
version='1.0.0',
17+
version='1.0.1',
1818
license='Apache V2.0 License',
1919
description='Douyin/TikTok async data scraper.',
2020
long_description=long_description,

tikhub/api.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# @Author: https://github.com/orgs/TikHubIO
44
# @Time: 2022/12/15
55
# @Update: 2022/12/19
6-
# @Version: 1.0.0
6+
# @Version: 1.0.1
77
# @Description: Douyin/TikTok async data scraper, base on TikHub API.
88

99

@@ -324,7 +324,7 @@ async def async_test() -> None:
324324

325325
douyin_url = 'https://www.douyin.com/video/7153585499477757192'
326326

327-
douyin_user_url = 'https://www.douyin.com/user/MS4wLjABAAAA-Hu1YKTuhE3QkCHD5yU26k--RUZiaoMRtpfmeid-Z_o'
327+
douyin_user_url = 'https://www.douyin.com/user/MS4wLjABAAAAaNJuvXC83kL5nhaZHubKdjsRJQovgz58wXzlLnJUsslG-Kb24TM1QJlf_2HMaUJk'
328328

329329
print("Test start...\n")
330330
start_time = time.time()
@@ -377,6 +377,7 @@ async def async_test() -> None:
377377
# 获取用户主页的所有点赞视频数据/Get all liked video data on the user's homepage
378378
print("Running test : API.get_douyin_profile_liked_videos()")
379379
aweme_list = await api.get_douyin_profile_liked_videos(douyin_user_url, 20)
380+
print(f'Get {len(aweme_list)} liked videos from profile')
380381

381382
# 总耗时/Total time
382383
total_time = round(time.time() - start_time, 2)

0 commit comments

Comments
 (0)