-
Notifications
You must be signed in to change notification settings - Fork 32
/
getChallengeFeed.py
55 lines (47 loc) · 1.41 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
from TiktokApi import *
import time
Api = Tiktok()
# hashtag's name
challengename = 'funny'
url = 'https://tiktok.com/tag/%s' % challengename
Api.openBrowser(url, show_br=True)
input('Skip the captcha, press Enter to continue ')
limit = 40
count = 0
first = True
flag = 0
cursor = 0
secUid = ''
while True:
if first == True:
data = Api.getChallengeFeed(first=first)
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
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=str(cursor), first=first)
for x in data['itemList']:
video_id = x['id']
caption = x['desc']
print("Video <<%s>> <<%s>>" % (str(video_id), str(caption)))
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()