1
1
<div align =" center " >
2
2
3
- # [ tikhub_pp ] ( https://pypi.org/project/tikhub )
3
+ # [ tikhub_op_pp ] ( https://pypi.org/project/tikhub )
4
4
5
5
「[ api.tikhub.io] ( https://api.tikhub.io/docs ) ", is an asynchronous high-performance Douyin and TikTok data crawling online tool. This repo is a package based on this API, which is convenient for developers to call.
6
6
@@ -10,69 +10,21 @@ Pee:<https://pypi.org/project/tikhub>
10
10
11
11
</div >
12
12
13
- ## note
13
+ ## 使用示例
14
14
15
- > This project uses the following Emoji to indicate the development status in the development chart!
15
+ > Check [ test.py ] ( https://github.com/TikHubIO/TikHub_PyPi/blob/main/test/test.py )
16
16
17
- | Emoji | representative meaning |
18
- | :---: | :-------------------------------------------------------------------------------------------------------------------: |
19
- | 🚀 | Rocket - The feature is written, tested, and deployed to production. |
20
- | ✅ | Check mark - the feature is written, but has yet to be tested and will be deployed to production once the tests pass. |
21
- | ❌ | Cross sign - The feature has not yet been written or has not been written yet. |
22
- | 🔜 | SOON BREAK - Feature proposed but not yet assigned a designated developer. |
23
- | ⚠️ | Warning symbol - There is a problem with the function that needs to be fixed. |
17
+ - Install
24
18
25
- ## project progress
26
-
27
- | state | API endpoint path | Function |
28
- | :---: | :---------------: | :--------------------: |
29
- | 🚀 | ` /token ` | generate` Bearer Token ` |
30
- | 🚀 | ` /users/me/ ` | Get user information |
31
-
32
- > Requirements for each interface endpoint
33
-
34
- | state | support platform | need | start date | ETA date | Developer |
35
- | :---: | :--------------- | :----------------------------------------------: | :--------: | :-------: | :--------: |
36
- | 🚀 | Douyin, TikTok | Crawl a single video data | 2022/10/08 | completed | @Evil0ctal |
37
- | 🚀 | Douyin, TikTok | Crawl a single video comment data | 2022/10/08 | completed | @Evil0ctal |
38
- | 🚀 | Douyin, TikTok | Crawl the soundtrack data | 2022/10/08 | completed | @Evil0ctal |
39
- | 🚀 | Douyin, TikTok | Crawl user homepage video data | 2022/10/08 | completed | @Evil0ctal |
40
- | 🚀 | Douyin, TikTok | Crawl the user homepage has liked the video data | 2022/10/08 | completed | @Evil0ctal |
41
-
42
- > Production and deployment of Douyin-related interfaces - API tags: Douyin
43
-
44
- | state | API endpoint path | Function | issue |
45
- | :---: | :-----------------------------: | :----------------------------------------------: | :-------------------: |
46
- | 🚀 | ` /douyin_video_data/ ` | Crawl a single video data | no known issues |
47
- | ⚠️ | ` /douyin_video_comments/ ` | Crawl a single video comment data | Invalid to be updated |
48
- | ⚠️ | ` /douyin_music_videos/ ` | Crawl the soundtrack data | Invalid to be updated |
49
- | 🚀 | ` /douyin_profile_videos/ ` | Crawl user homepage video data | no known issues |
50
- | 🚀 | ` /douyin_profile_liked_videos/ ` | Crawl the user homepage has liked the video data | no known issues |
51
-
52
- > Production deployment of TikTok-related interfaces - API tags: TikTok
53
-
54
- | state | API endpoint path | Function | issue |
55
- | :---: | :-----------------------------: | :----------------------------------------------: | :-------------: |
56
- | 🚀 | ` /tiktok_video_data/ ` | Crawl a single video data | no known issues |
57
- | 🚀 | ` /tiktok_video_comments/ ` | Crawl a single video comment data | no known issues |
58
- | 🚀 | ` /tiktok_music_videos/ ` | Crawl the soundtrack data | no known issues |
59
- | 🚀 | ` /tiktok_profile_videos/ ` | Crawl user homepage video data | no known issues |
60
- | 🚀 | ` /tiktok_profile_liked_videos/ ` | Crawl the user homepage has liked the video data | no known issues |
61
-
62
- ## to do` Todo ` the list
63
-
64
- - [ ] ⚠️ fix` /douyin_video_comments/ ` endpoint
65
- - [ ] ⚠️ fix` /douyin_music_videos/ ` endpoint
66
-
67
- ## Example of use
19
+ ``` bash
20
+ pip install tikhub
21
+ ```
68
22
69
- > Check [ demo.py ] ( https://github.com/TikHubIO/TikHub_PyPi/blob/main/demo/demo.py )
23
+ - Usage
70
24
71
25
``` python
72
- import asyncio
73
- import time
26
+ from tikhub.api import *
74
27
75
- from tikhub.api import API
76
28
77
29
async def async_test () -> None :
78
30
# 异步测试/Async test
@@ -89,54 +41,62 @@ async def async_test() -> None:
89
41
start_time = time.time()
90
42
91
43
# 获取TikHub请求头/Get TikHub request header
92
- print (" Running test : API.authenticate()" )
93
- await api.authenticate()
44
+ r = await api.user_login()
45
+ print (" Running test : API.user_login()" )
46
+ print (r)
94
47
95
48
# 获取TikHub用户信息/Get TikHub user information
96
49
print (" Running test : API.get_user_info()" )
97
- await api.get_user_info()
50
+ r = await api.get_user_info()
51
+ print (r)
98
52
99
53
print (" \n Running ALL TikTok methods test...\n " )
100
54
101
55
# 获取单个视频数据/Get single video data
102
56
print (" Running test : API.get_tiktok_video_data()" )
103
- await api.get_tiktok_video_data(tiktok_url)
57
+ r = await api.get_tiktok_video_data(tiktok_url)
58
+ # print(r)
104
59
105
60
# 获取获取用户主页的所有视频数据/Get all video data on the user's homepage
106
61
print (" Running test : API.get_tiktok_profile_videos()" )
107
- aweme_list = await api.get_tiktok_profile_videos(tiktok_url, 20 )
108
- print (f ' Get { len (aweme_list )} videos from profile ' )
62
+ r = await api.get_tiktok_profile_videos(tiktok_url, cursor = None , count = None , get_all = False )
63
+ print (f ' Get { len (r )} videos from profile ' )
109
64
110
65
# 获取用户主页的所有点赞视频数据/Get all liked video data on the user's homepage
111
66
print (" Running test : API.get_tiktok_profile_liked_videos()" )
112
- aweme_list = await api.get_tiktok_profile_liked_videos(tiktok_url, 20 )
113
- print (f ' Get { len (aweme_list )} liked videos from profile ' )
67
+ r = await api.get_tiktok_profile_liked_videos(tiktok_url, cursor = None , count = None , get_all = False )
68
+ print (f ' Get { len (r )} liked videos from profile ' )
114
69
115
70
# 获取TikTok视频的所有评论数据/Get all comment data of TikTok video
116
71
print (" Running test : API.get_tiktok_video_comments()" )
117
- comments_list = await api.get_tiktok_video_comments(tiktok_url, 20 )
118
- print (f ' Get { len (comments_list )} comments from video ' )
72
+ r = await api.get_tiktok_video_comments(tiktok_url, cursor = None , count = None , get_all = False )
73
+ print (f ' Get { len (r )} comments from video ' )
119
74
120
75
# 获取音乐页面上的所有(理论上能抓取到的)视频数据/Get all (theoretically) video data on the music page
121
76
print (" Running test : API.get_tiktok_music_videos()" )
122
- aweme_list = await api.get_tiktok_music_videos(tiktok_music_url, 20 )
123
- print (f ' Get { len (aweme_list )} videos from music ' )
77
+ r = await api.get_tiktok_music_videos(tiktok_music_url, cursor = None , count = None , get_all = False )
78
+ print (f ' Get { len (r )} videos from music ' )
124
79
125
80
print (" \n Running ALL Douyin methods test...\n " )
126
81
127
82
# 获取单个视频数据/Get single video data
128
83
print (" Running test : API.get_douyin_video_data()" )
129
- await api.get_douyin_video_data(douyin_url)
84
+ r = await api.get_douyin_video_data(douyin_url)
130
85
131
86
# 获取获取用户主页的所有视频数据/Get all video data on the user's homepage
132
87
print (" Running test : API.get_douyin_profile_videos()" )
133
- aweme_list = await api.get_douyin_profile_videos(douyin_user_url, 20 )
134
- print (f ' Get { len (aweme_list )} videos from profile ' )
88
+ r = await api.get_douyin_profile_videos(douyin_user_url, cursor = None , count = None , get_all = False )
89
+ print (f ' Get { len (r )} videos from profile ' )
135
90
136
91
# 获取用户主页的所有点赞视频数据/Get all liked video data on the user's homepage
137
92
print (" Running test : API.get_douyin_profile_liked_videos()" )
138
- aweme_list = await api.get_douyin_profile_liked_videos(douyin_user_url, 20 )
139
- print (f ' Get { len (aweme_list)} liked videos from profile ' )
93
+ r = await api.get_douyin_profile_liked_videos(douyin_user_url, cursor = None , count = None , get_all = False )
94
+ print (f ' Get { len (r)} liked videos from profile ' )
95
+
96
+ # 获取抖音视频的所有评论数据/Get all comment data of Douyin video
97
+ print (" Running test : API.get_douyin_video_comments()" )
98
+ r = await api.get_douyin_video_comments(douyin_url, cursor = None , count = None , get_all = False )
99
+ print (f ' Get { len (r)} comments from video ' )
140
100
141
101
# 总耗时/Total time
142
102
total_time = round (time.time() - start_time, 2 )
@@ -145,9 +105,10 @@ async def async_test() -> None:
145
105
146
106
if __name__ == ' __main__' :
147
107
api = API(
148
- username = ' test ' ,
149
- password = ' test ' ,
108
+
109
+ password = ' PASSWORD ' ,
150
110
proxy = None ,
151
111
)
152
112
asyncio.run(async_test())
113
+
153
114
```
0 commit comments