-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLokerId.py
215 lines (184 loc) · 10.5 KB
/
LokerId.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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
"""
program ini merupakan aplikasi bot sederhana yang bertujuan untuk mengumpulkan data lowongan pekerjaan dari web Loker.id.
data yang dikumpulkan akan disimpan terlebih dahulu pada fitur Bookmark Loker.id agar tidak diperlukan membuat database.
setelah data tersimpan, bot akan melakukan apply pada lowongan tersebut secara otomatis.
untuk menjalankanya, diperlukan driver geckowebdriver yang terinstall pada OS.
"""
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import pymysql as db
import time
import random
#---------------------------------------------------------------------
#https://www.loker.id/cari-lowongan-kerja?q=backend+developer&lokasi=0&category=information-technology&pendidikan=sarjana-s1
class KarirID:
def __init__(self, username, password):
self.username = username
self.password = password
self.driver = webdriver.Firefox()
def closeBrowser(self):
self.driver.close()
def koneksi():
conn = db.connect('localhost', 'root', '', 'test_rest_api')
cur = conn.cursor()
return conn, cur
def login(self):
try:
driver = self.driver
driver.get("https://www.loker.id/login")
time.sleep(2)
user_name_elem = driver.find_element_by_xpath("//input[@name='acf[field_574b31195165b]']")
user_name_elem.clear()
user_name_elem.send_keys(self.username)
password_elem = driver.find_element_by_xpath("//input[@name='acf[field_574b311951bc8]']")
password_elem.clear()
password_elem.send_keys(self.password)
password_elem.send_keys(Keys.RETURN)
time.sleep(2)
except Exception:
print("ada yang salah nih di login")
def cari_kerja(self):
driver = self.driver
driver.get("https://www.loker.id/cari-lowongan-kerja?q=&lokasi=0&category=information-technology&pendidikan=sarjana-s1")
#----------------------------Untuk Page 1---------------------------------
for i in range(2,11):
try:
tombol_simpan = driver.find_element_by_xpath("//html/body/div[2]/div/div[2]/div/div["+ str(i) +"]/div[2]/div[2]")
tombol_simpan.click()
time.sleep(random.randint(1,4))
tombol_verif = driver.find_element_by_xpath("//html/body/div[6]/div[7]/div/button")
tombol_verif.click()
print("Berhasil Di Bookmark")
except Exception:
print("sudah di bookmark")
continue
#----------------------------Untuk Page 2 - 18 ---------------------------------
for j in range(2,19):
try:
driver.get("https://www.loker.id/cari-lowongan-kerja/page/"+ str(j) +"?q&lokasi=0&category=information-technology&pendidikan=sarjana-s1")
for k in range(2,11):
try:
tombol_simpan = driver.find_element_by_xpath("//html/body/div[2]/div/div[2]/div/div["+ str(k) +"]/div[2]/div[2]")
tombol_simpan.click()
time.sleep(random.randint(1,4))
tombol_verif = driver.find_element_by_xpath("//html/body/div[6]/div[7]/div/button")
tombol_verif.click()
print("Berhasil Di Bookmark")
except Exception:
print("sudah di bookmark")
continue
except Exception:
print("ada yang salah")
continue
def book(self):
deskripsi_diri = "deskripsi diri anda"
driver = self.driver
driver.get("https://www.loker.id/bookmark")
halaman_lowongan = []
#----------------------------Untuk Page 1---------------------------------
for i in range(1,11):
try:
simpan_halaman_loker = driver.find_element_by_xpath("//html/body/div[2]/div[2]/div/div[2]/div/div/table/tbody/tr["+ str(i) +"]/td[1]/h5/a")
link_halaman = simpan_halaman_loker.get_attribute('href')
halaman_lowongan.append(link_halaman)
#print("Link loker ke-"+ str(i) + "ialah" + halaman_lowongan[i])
except Exception:
print("ada yang salah di rekursif saat mengambil link halaman")
#print(halaman_lowongan)
for j in range(0,len(halaman_lowongan)):
driver.get(halaman_lowongan[j])
try:
button_lamar_pekerjaan=driver.find_element_by_xpath("/html/body/div[2]/div[1]/div/div/div[1]/div/div/div[2]/div[3]/div/div[3]/a")
button_lamar_pekerjaan.click()
except Exception:
print("Lamaran telah dikirim sebelumnya")
continue
time.sleep(5)
#pilih_resume = driver.find_element_by_xpath("//html/body/div[2]/div[1]/div/div/div[1]/div/div/div[2]/div[3]/div/div[3]/div/div/div/form/div[1]/div[3]/div[1]/div[2]/div/a")
pilih_resume = driver.find_element_by_xpath("//html/body/div[2]/div[1]/div/div/div[1]/div/div/div[2]/div[3]/div/div[3]/div/div/div/form/div[1]/div[3]/div[1]/div[2]/span/span[1]/span/span[2]")
pilih_resume.click()
time.sleep(3)
#-------------Opsional 1-----------------------------
"""
resum = driver.find_element_by_xpath("//input[@id='s2id_autogen1_search']")
resum.send_keys("nama reseume anda")
resum.send_keys(Keys.ENTER)
"""
#------------Opsional 2------------------------------------
resum = driver.find_element_by_xpath("//ul[@id='select2-acf-field_57a6d61c2671c-results']")
resum.click()
deskrip = driver.find_element_by_xpath("//textarea[@id='acf-field_57af7454a90bf']")
deskrip.send_keys(deskripsi_diri)
#time.sleep(10)
button_kirim = driver.find_element_by_xpath("/html/body/div[2]/div[1]/div/div/div[1]/div/div/div[2]/div[3]/div/div[3]/div/div/div/form/div[2]/button[2]")
button_kirim.click()
print("lamaran " +str(j)+" Berhasil di kirim")
for k in range(0,len(halaman_lowongan)):
try:
time.sleep(1)
del halaman_lowongan[0]
except Exception:
print("Error saat menghapus list halaman_lowongan" + str(k))
#----------------------------Untuk Page 2 Dst---------------------------------
for x in range(2,99):
try:
driver.get("https://www.loker.id/bookmark/page/"+str(x))
print("=================================Halaman "+str(x)+"===========================")
print(" ")
for i in range(1,11):
try:
simpan_halaman_loker = driver.find_element_by_xpath("//html/body/div[2]/div[2]/div/div[2]/div/div/table/tbody/tr["+ str(i) +"]/td[1]/h5/a")
link_halaman = simpan_halaman_loker.get_attribute('href')
halaman_lowongan.append(link_halaman)
#print("Link loker ke-"+ str(i) + "ialah" + halaman_lowongan[i])
except Exception:
print("ada yang salah di rekursif saat mengambil link halaman")
break
#print(halaman_lowongan)
for j in range(0,len(halaman_lowongan)):
driver.get(halaman_lowongan[j])
try:
button_lamar_pekerjaan=driver.find_element_by_xpath("/html/body/div[2]/div[1]/div/div/div[1]/div/div/div[2]/div[3]/div/div[3]/a")
button_lamar_pekerjaan.click()
except Exception:
print("Lamaran telah dikirim sebelumnya")
continue
try:
#pilih_resume = driver.find_element_by_xpath("/html/body/div[2]/div[1]/div/div/div[1]/div/div/div[2]/div[3]/div/div[3]/div/div/div/form/div[1]/div[3]/div[1]/div[2]/div/a")
pilih_resume = driver.find_element_by_xpath("//html/body/div[2]/div[1]/div/div/div[1]/div/div/div[2]/div[3]/div/div[3]/div/div/div/form/div[1]/div[3]/div[1]/div[2]/span/span[1]/span/span[2]")
pilih_resume.click()
time.sleep(3)
#-------------Opsional 1-----------------------------
"""
resum = driver.find_element_by_xpath("//input[@id='s2id_autogen1_search']")
resum.send_keys("nama resume anda")
resum.send_keys(Keys.ENTER)
"""
#------------Opsional 2------------------------------------
resum = driver.find_element_by_xpath("//ul[@id='select2-acf-field_57a6d61c2671c-results']")
resum.click()
deskrip = driver.find_element_by_xpath("//textarea[@id='acf-field_57af7454a90bf']")
deskrip.send_keys(deskripsi_diri)
#time.sleep(10)
button_kirim = driver.find_element_by_xpath("/html/body/div[2]/div[1]/div/div/div[1]/div/div/div[2]/div[3]/div/div[3]/div/div/div/form/div[2]/button[2]")
button_kirim.click()
print("lamaran " +str(j)+" Berhasil di kirim")
except Exception:
print("ada yang salah dimari")
break
for y in range(0,len(halaman_lowongan)):
try:
time.sleep(1)
del halaman_lowongan[0]
except Exception:
print("Error saat menghapus list halaman_lowongan bagian 2 dst")
except Exception:
print("Halaman udah habis")
break
Nama = 'Masukkan Nama resume anda disini'
User_anda = 'Masukkan username akun karir.id anda di sini'
Pass_anda = 'Masukkan password akun karir.id anda di sini'
akun = KarirID(User_anda, Pass_anda)
akun.login()
akun.book()
akun.cari_kerja()