-
Notifications
You must be signed in to change notification settings - Fork 1
/
GoToCampPulse.py
59 lines (43 loc) · 1.51 KB
/
GoToCampPulse.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
import requests
import pymongo
import time
import datetime
import progressbar
from users import users
client = pymongo.MongoClient()
db = client.main
while True:
url = "https://api.vk.com/method/users.get?fields=online&user_ids="
online_counter = 0
bar = progressbar.ProgressBar()
for i in bar(range(60)):
time.sleep(1)
print("================================================\n")
datetime_now = datetime.datetime.fromtimestamp(time.time()).strftime('%c')
print(datetime_now)
print("\n================================================\n")
print(str(len(users)) + " people:\n")
for user_id in users:
url += user_id + ","
profiles = requests.get(url).json()['response']
for user in profiles:
first_name = user['first_name']
last_name = user['last_name']
is_online = user['online']
uid = user['uid']
if is_online:
online_counter += 1
online_message = "is not online" if not is_online else "is online"
if 'online_mobile' in user.keys():
print(first_name + " " + last_name + " " + online_message, end="")
print(" from mobile site or app")
else:
print(first_name + " " + last_name + " " + online_message)
with open("last_number.txt", "w") as last_record:
last_record.write(str(online_counter))
db.user_stats.insert_one(
{
str(int(time.time())): profiles
}
)
print("\n>>>>>" + str(online_counter) + "<<<<")