-
Notifications
You must be signed in to change notification settings - Fork 0
/
custom_functions.py
105 lines (77 loc) · 3.17 KB
/
custom_functions.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
import pyautogui
import random
import time
from random_address import real_random_address_by_postal_code
def tab_sleep():
pyautogui.press('tab')
time.sleep(0.5)
def space_sleep():
pyautogui.press('space')
time.sleep(0.5)
def write_sleep(string):
pyautogui.write(string, random.uniform(0.1, 1))
time.sleep(0.5)
def down_sleep():
pyautogui.press('down')
time.sleep(0.5)
def enter_sleep():
pyautogui.press('enter')
time.sleep(0.5)
# ---------------------------------------
# these functions sleep for a random period of time. This is so the bot will mimic the way humans pause for random periods of time while filling out the form. The goal is for the bot to be indistinguishable from a human user, so it needs to mimic human behavior
def tab_rand_sleep():
pyautogui.press('tab')
time.sleep(random.uniform(0.5, 2))
def space_rand_sleep():
pyautogui.press('space')
time.sleep(random.uniform(0.5, 2))
def write_rand_sleep(string):
pyautogui.write(string, random.uniform(0.1, 0.6))
time.sleep(random.uniform(0.5, 2))
def down_rand_sleep():
pyautogui.press('down')
time.sleep(random.uniform(0.5, 2))
def enter_rand_sleep():
pyautogui.press('enter')
time.sleep(random.uniform(0.5, 2))
def write_rs_tab_rs(string): # write_rand_sleep() then tab_rand_sleep()
write_rand_sleep(string)
tab_rand_sleep()
def for_tab_sleep_range(x):
for tab in range(x):
tab_rand_sleep()
# --------------------------------------
email_providers = ["@gmail.com", "@outlook.com", "@yahoo.com", "@protonmail.com", "@aol.com", "@icloud.com"]
def generate_email(first_name, last_name):
num = str(random.choice(range(1, 99)))
provider = random.choice(email_providers)
return f"{first_name}{last_name}{num}{provider}".lower()
area_codes = ["202", "771", "276", "434", "804", "240", "301", "410", "443", "667"]
def generate_phone():
num = str(random.choice(range(2345678, 8765432))) # 202-9999999
area_code = random.choice(area_codes)
return f"{area_code}{num}"
relatives = ["grandparent", "godparent", "uncle", "aunt"]
def generate_relationship():
return random.choice(relatives)
zip_codes = ["20001", "20002", "20009", "20010", "20012", "20017", "20018", "20020", "20032", "20036"]
def generate_address():
zip_code = random.choice(zip_codes)
address = real_random_address_by_postal_code(zip_code)
return address
def generate_random_date(input):
random_month = str(random.choice(range(1, 13)))
random_day = str(random.choice(range(1, 29)))
# validate input passed to the function. This decides the range for the random year
if input == "child":
random_year = str(random.choice(range(2013, 2019)))
elif input == "parent":
random_year = str(random.choice(range(1970, 1990)))
else:
print(f"[!] ERROR in generate_random_date() input")
# if the day or month is only one digit, add a 0 in front of it (all random days and months need to be 2 digits)
if len(random_day) == 1:
random_day = f"0{random_day}"
if len(random_month) == 1:
random_month = f"0{random_month}"
return f"{random_month}{random_day}{random_year}" # MMDDYYYY