-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathlambda_function.py
More file actions
42 lines (37 loc) · 1.23 KB
/
lambda_function.py
File metadata and controls
42 lines (37 loc) · 1.23 KB
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 TiktokFollowInfo import TiktokFollowInfo
def lambda_handler(event, context):
depth = 1
request_count = 10
if 'url' not in event:
raise ValueError("No Avaliable Url Avaliable!")
if 'MAX_DEPTH' not in event:
depth = 1
TiktokFollowInfo.MAX_DEPTH = depth
else:
depth = event['MAX_DEPTH']
TiktokFollowInfo.MAX_DEPTH = depth
if 'REQUEST_SEND_LIMIT' not in event:
request_count = 10
TiktokFollowInfo.REQUEST_SEND_LIMIT = request_count
else:
request_count = event['REQUEST_SEND_LIMIT']
TiktokFollowInfo.REQUEST_SEND_LIMIT = request_count
count = 0
url = event['url']
threadPool = []
Parent = TiktokFollowInfo(url, getFollowing = 'false')
threadPool.append(Parent)
while count < request_count:
for i in threadPool:
i.start()
for i in threadPool:
i.join()
newPool = []
count += 1
if count >= TiktokFollowInfo.DEPTH_LIMIT:
break
for i in threadPool:
for j in i.allresponses:
temp = TiktokFollowInfo(url, getFollowing = 'true', secUid = j['secUid'])
newPool.append(temp)
threadPool = newPool