-
Notifications
You must be signed in to change notification settings - Fork 0
/
getChallengeFeed.py
62 lines (46 loc) · 1.28 KB
/
getChallengeFeed.py
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
from TiktokApi import *
Api = Tiktok()
# hashtag's name
challengename = 'funny'
url = 'https://tiktok.com/tag/%s' % challengename
Api.openBrowser(url)
limit = 40
count = 0
first = True
flag = 0
cursor = 0
secUid = ''
dl = Download()
while True:
if first == True:
data = Api.getChallengeFeed(first=first)
for x in data['ItemModule']:
# show video ID
print(data['ItemModule'][x]['id'])
# show video caption
# print(data['ItemModule'][x]['desc'])
count += 1
if count == limit:
flag = 1
break
if not data['ItemList']['challenge']['hasMore']:
break
cursor = data['ItemList']['challenge']['cursor']
ch_id = data['ChallengePage']['challengeInfo']['challenge']['id']
else:
data = Api.getChallengeFeed(ch_id=ch_id, cursor=cursor, first=first)
for x in data['itemList']:
# print(str(x['desc']))
print(str(x['id']))
count += 1
if count == limit:
flag = 1
break
if not data['hasMore']:
break
cursor = data['cursor']
if flag == 1:
break
first = False
# break
Api.closeBrowser()