forked from madingess/EasyApplyBot
-
-
Notifications
You must be signed in to change notification settings - Fork 39
Expand file tree
/
Copy pathmain.py
More file actions
147 lines (126 loc) · 5.21 KB
/
main.py
File metadata and controls
147 lines (126 loc) · 5.21 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
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
import yaml, os
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome.service import Service
from validate_email import validate_email
from webdriver_manager.chrome import ChromeDriverManager
from linkedineasyapply import LinkedinEasyApply
def init_browser():
browser_options = Options()
options = [
'--disable-blink-features',
'--no-sandbox',
'--start-maximized',
'--disable-extensions',
'--ignore-certificate-errors',
'--disable-blink-features=AutomationControlled',
'--remote-debugging-port=9222'
]
# Restore session if possible (avoids login everytime)
user_data_dir = os.path.join(os.getcwd(), "chrome_bot")
browser_options.add_argument(f"user-data-dir={user_data_dir}")
for option in options:
browser_options.add_argument(option)
service = Service(ChromeDriverManager().install())
driver = webdriver.Chrome(service=service, options=browser_options)
driver.implicitly_wait(1) # Wait time in seconds to allow loading of elements
driver.set_window_position(0, 0)
driver.maximize_window()
return driver
def validate_yaml():
with open("config.yaml", 'r', encoding='utf-8') as stream:
try:
parameters = yaml.safe_load(stream)
except yaml.YAMLError as exc:
raise exc
mandatory_params = ['email',
'password',
'disableAntiLock',
'remote',
'lessthanTenApplicants',
'experienceLevel',
'jobTypes',
'date',
'positions',
'locations',
'residentStatus',
'distance',
'outputFileDirectory',
'checkboxes',
'universityGpa',
'languages',
'experience',
'personalInfo',
'eeo',
'uploads']
for mandatory_param in mandatory_params:
if mandatory_param not in parameters:
raise Exception(mandatory_param + ' is not defined in the config.yaml file!')
assert validate_email(parameters['email'])
assert len(str(parameters['password'])) > 0
assert isinstance(parameters['disableAntiLock'], bool)
assert isinstance(parameters['remote'], bool)
assert isinstance(parameters['lessthanTenApplicants'], bool)
assert isinstance(parameters['residentStatus'], bool)
assert len(parameters['experienceLevel']) > 0
experience_level = parameters.get('experienceLevel', [])
at_least_one_experience = False
for key in experience_level.keys():
if experience_level[key]:
at_least_one_experience = True
assert at_least_one_experience
assert len(parameters['jobTypes']) > 0
job_types = parameters.get('jobTypes', [])
at_least_one_job_type = False
for key in job_types.keys():
if job_types[key]:
at_least_one_job_type = True
assert at_least_one_job_type
assert len(parameters['date']) > 0
date = parameters.get('date', [])
at_least_one_date = False
for key in date.keys():
if date[key]:
at_least_one_date = True
assert at_least_one_date
approved_distances = {0, 5, 10, 25, 50, 100}
assert parameters['distance'] in approved_distances
assert len(parameters['positions']) > 0
assert len(parameters['locations']) > 0
assert len(parameters['uploads']) >= 1 and 'resume' in parameters['uploads']
assert len(parameters['checkboxes']) > 0
checkboxes = parameters.get('checkboxes', [])
assert isinstance(checkboxes['driversLicence'], bool)
assert isinstance(checkboxes['requireVisa'], bool)
assert isinstance(checkboxes['legallyAuthorized'], bool)
assert isinstance(checkboxes['certifiedProfessional'], bool)
assert isinstance(checkboxes['urgentFill'], bool)
assert isinstance(checkboxes['commute'], bool)
assert isinstance(checkboxes['backgroundCheck'], bool)
assert isinstance(checkboxes['securityClearance'], bool)
assert 'degreeCompleted' in checkboxes
assert isinstance(parameters['universityGpa'], (int, float))
languages = parameters.get('languages', [])
language_types = {'none', 'conversational', 'professional', 'native or bilingual'}
for language in languages:
assert languages[language].lower() in language_types
experience = parameters.get('experience', [])
for tech in experience:
assert isinstance(experience[tech], int)
assert 'default' in experience
assert len(parameters['personalInfo'])
personal_info = parameters.get('personalInfo', [])
for info in personal_info:
assert personal_info[info] != ''
assert len(parameters['eeo'])
eeo = parameters.get('eeo', [])
for survey_question in eeo:
assert eeo[survey_question] != ''
return parameters
if __name__ == '__main__':
parameters = validate_yaml()
browser = init_browser()
bot = LinkedinEasyApply(parameters, browser)
bot.login()
bot.security_check()
bot.start_applying()