forked from madingess/EasyApplyBot
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.py
More file actions
116 lines (90 loc) · 3.99 KB
/
main.py
File metadata and controls
116 lines (90 loc) · 3.99 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
import yaml
from linkedineasyapply import LinkedinEasyApply
from validate_email import validate_email
from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.chrome.options import Options
def init_browser():
browser_options = Options()
options = ['--disable-blink-features', '--no-sandbox', '--disable-extensions',
'--ignore-certificate-errors', '--disable-blink-features=AutomationControlled','--disable-gpu','--remote-debugging-port=9222']
for option in options:
browser_options.add_argument(option)
driver = webdriver.Chrome(options=browser_options)
return driver
def validate_yaml():
with open("config.yaml", 'r') as stream:
try:
parameters = yaml.safe_load(stream)
except yaml.YAMLError as exc:
raise exc
mandatory_params = ['email', 'password', 'disableAntiLock', 'remote', 'experienceLevel', 'jobTypes', 'date',
'positions', 'locations', '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 inside the yml file!')
assert validate_email(parameters['email'])
assert len(str(parameters['password'])) > 0
assert isinstance(parameters['disableAntiLock'], bool)
assert isinstance(parameters['remote'], 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['urgentFill'], bool)
assert isinstance(checkboxes['commute'], bool)
assert isinstance(checkboxes['backgroundCheck'], 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()