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