-
Notifications
You must be signed in to change notification settings - Fork 33
/
getUserFeed.py
60 lines (49 loc) · 1.44 KB
/
getUserFeed.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
import sys
sys.stdin.reconfigure(encoding='utf-8')
sys.stdout.reconfigure(encoding='utf-8')
from TiktokApi import *
Api = Tiktok()
# edit username here
username = 'tiktok'
url = 'https://tiktok.com/@%s' % username
Api.openBrowser(url, 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.getUserFeed(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']['user-post']['hasMore']:
break
cursor = data['ItemList']['user-post']['cursor']
secUid = data['UserPage']['secUid']
else:
data = Api.getUserFeed(secUid=secUid, cursor=cursor, first=first)
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 not data['hasMore']:
break
cursor = data['cursor']
if flag == 1:
break
first = False
# break
Api.closeBrowser()