-
Notifications
You must be signed in to change notification settings - Fork 1
/
tiktok.py
70 lines (56 loc) · 1.8 KB
/
tiktok.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
63
64
65
66
67
68
69
70
from time import sleep
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from getpass import getpass
import subprocess
import random
import string
from selenium.webdriver.chrome.options import Options
from playsound import playsound
#variables
check_delay = 10
username = "jasonfairfield"
sound = "bruh.mp3"
#reset follower count
with open("followers.txt", "w") as myfile:
myfile.write("0")
driver = webdriver.Edge("C:\\MEGA\\Python\\Tiktok\\msedgedriver.exe")
driver.set_window_size(300, 350)
driver.implicitly_wait(5)
driver.get('https://livecounts.io/embed/tiktok-realtime/{}'.format(username))
sleep(4)
prev_follows = "0"
with open("followers.txt") as file:
prev_follows = file.read()
def scrape():
global prev_follows
followers = "0"
with open("followers.txt") as file:
followers = file.read()
print(followers)
if (followers != "0"):
if (prev_follows != followers):
dif = int(followers) - int(prev_follows)
if (dif > 0):
for y in range(dif):
playsound(sound)
prev_follows = followers
else:
pass
with open("followers.txt", "w") as myfile:
myfile.write("")
#Scrape live count
digits = driver.find_elements_by_css_selector('.odometer-value')
for x in digits:
value = x.text
with open("followers.txt", "a") as myfile:
myfile.seek(0)
myfile.write(value)
if (prev_follows == "0"):
with open("followers.txt") as file:
prev_follows = file.read()
print("starter followers: " + prev_follows)
sleep(check_delay)
scrape()
scrape()
command = "taskkill /F /IM msedgedriver.exe /T"