forked from NathanDuma/LinkedIn-Easy-Apply-Bot
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
160 lines (119 loc) · 5.18 KB
/
main.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
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
148
149
150
151
152
153
154
155
156
import yaml
import pdb
import requests
import wget
import zipfile
import os
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from webdriver_manager.chrome import ChromeDriverManager
from linkedineasyapply import LinkedinEasyApply
# import validate_email
from selenium.webdriver.chrome.service import Service
def init_browser():
browser_options = Options()
options = ['--disable-blink-features', '--no-sandbox', '--start-maximized', '--disable-extensions',
'--ignore-certificate-errors', '--disable-blink-features=AutomationControlled']
for option in options:
browser_options.add_argument(option)
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=browser_options)
# driver = webdriver.Chrome()
driver.set_window_position(0, 0)
driver.maximize_window()
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', 'industry', 'technology', '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
industry = parameters.get('industry', [])
for skill in industry:
assert isinstance(industry[skill], int)
assert 'default' in industry
technology = parameters.get('technology', [])
for tech in technology:
assert isinstance(technology[tech], int)
assert 'default' in technology
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
def chromium_install():
# totally legally acquired this from Stack Overflow.
# get the latest chrome driver version number
url = 'https://chromedriver.storage.googleapis.com/LATEST_RELEASE'
response = requests.get(url)
version_number = response.text
# build the donwload url
download_url = "https://chromedriver.storage.googleapis.com/" + version_number + "/chromedriver_win32.zip"
# download the zip file using the url built above
latest_driver_zip = wget.download(download_url, 'chromedriver.zip')
# extract the zip file
with zipfile.ZipFile(latest_driver_zip, 'r') as zip_ref:
zip_ref.extractall() # you can specify the destination folder path here
# delete the zip file downloaded above
os.remove(latest_driver_zip)
if __name__ == '__main__':
chromium_install()
parameters = validate_yaml()
browser = init_browser()
bot = LinkedinEasyApply(parameters, browser)
bot.login()
bot.security_check()
bot.start_applying()