-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.py
93 lines (60 loc) · 2.06 KB
/
run.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
""" Modules import """
from datetime import datetime
from cryptography.fernet import Fernet
from src.driver import DriverPreparation
from src.services import Linkedin, Vagas
def set_driver():
"""
Returns url path from webdriver directory.
"""
driver = DriverPreparation()
chrome_driver = driver.chrome_driver()
return chrome_driver
def credentials(service):
"""
Returns login credentials.
"""
with open('C:/Users/mekyl/OneDrive/Documentos/chave.key', 'rb') as key_file:
key = key_file.read()
with open('./src/credentials_' + service + '.txt', 'r') as credentials_file:
lines = credentials_file.readlines()
fernet = Fernet(key)
return [fernet.decrypt(line.encode()).decode() for line in lines]
def use_linkedin(driver, email, password):
"""
Run LinkedIn process.
"""
linkedin = Linkedin(driver, email, password)
linkedin.login()
linkedin.logout()
def use_vagas(driver, email, password, job_description):
"""
Run Vagas process.
"""
vagas = Vagas(driver, email, password)
vagas.login()
applications = vagas.job_application(*job_description)
save_info_application(applications)
vagas.logout()
def save_info_application(informations):
"""
Create a file with informations about job application.
"""
date = datetime.now().strftime('%Y-%m-%d-%H%M%S')
with open('./applications/applications' + date + '.txt', 'w') as file:
for information in informations:
for key, value in information.items():
info = key + ': ' + value.replace('\n', '')
file.writelines(info + '\n')
file.writelines('\n')
def main(job_description, service='vagas'):
"""
Main function.
"""
driver = set_driver()
email, password = [*credentials(service)]
if service.lower().strip() == 'linkedin':
return use_linkedin(driver, email, password)
return use_vagas(driver, email, password, job_description)
if __name__ == '__main__':
main(job_description=['Coordenador 3D'])