-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathgetTrendingFeed.py
More file actions
43 lines (31 loc) · 873 Bytes
/
getTrendingFeed.py
File metadata and controls
43 lines (31 loc) · 873 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
from TiktokApi import *
Api = Tiktok()
Api.openBrowser()
limit = 40
count = 0
first = True
flag = 0
while True:
data = Api.getTrendingFeed(first=first)
if first == True:
for x in data['ItemModule']:
video_id = data['ItemModule'][x]['id']
caption = data['ItemModule'][x]['desc']
print("Video <<%s>> <<%s>>" % (str(video_id), str(caption)))
count += 1
if count == limit:
flag = 1
break
else:
for x in data['itemList']:
caption = str(x['desc'])
video_id = str(x['id'])
print("Video <<%s>> <<%s>>" % (str(video_id), str(caption)))
count += 1
if count == limit:
flag = 1
break
if flag == 1:
break
first = False
Api.closeBrowser()