1
+ import os
2
+ import time
3
+ import dotenv
4
+ from selenium import webdriver
5
+ from selenium .webdriver .common .by import By
6
+ from selenium .webdriver .edge .service import Service
7
+ from selenium .webdriver .edge .options import Options
8
+ from selenium .common .exceptions import NoSuchElementException
9
+
10
+ dotenv .load_dotenv ("config.env" , True )
11
+
12
+ MY_LID_EMAIL = os .environ .get ("MY_LID_EMAIL" )
13
+ MY_LID_PASS = os .environ .get ("MY_LID_PASS" )
14
+
15
+ service = Service ('C:\Development\chromedriver\msedgedriver.exe' )
16
+
17
+ options = Options ()
18
+ options .add_experimental_option ("detach" , True )
19
+ driver = webdriver .Edge (service = service , options = options )
20
+ driver .maximize_window ()
21
+ driver .get ('https://www.linkedin.com' )
22
+
23
+ # Log in
24
+ username = driver .find_element (By .ID , 'session_key' )
25
+ username .send_keys (MY_LID_EMAIL )
26
+ time .sleep (1 )
27
+ username = driver .find_element (By .ID , 'session_password' )
28
+ username .send_keys (MY_LID_PASS )
29
+ time .sleep (1 )
30
+ driver .find_element (By .XPATH , '//*[@id="main-content"]/section[1]/div/div/form/div[2]/button' ).click ()
31
+ time .sleep (5 )
32
+
33
+ driver .get ('https://www.linkedin.com/jobs/search/?f_AL=true&geoId=102713980&keywords=python%20developer&location=India&refresh=true' )
34
+ time .sleep (5 )
35
+
36
+ jobs = driver .find_elements (by = By .CLASS_NAME , value = 'job-card-list__title' )
37
+ jobs_available = [job .text for job in jobs ]
38
+ print (jobs_available )
39
+
40
+ # Select job posting and click on apply
41
+ while jobs_available :
42
+ posting_num = 0
43
+ try :
44
+ driver .find_element (by = By .LINK_TEXT , value = f'{ jobs_available [posting_num ]} ' ).click ()
45
+ time .sleep (2 )
46
+ driver .find_element (by = By .CLASS_NAME , value = "jobs-s-apply" ).click ()
47
+ except NoSuchElementException :
48
+ posting_num += 1
49
+ driver .find_element (by = By .LINK_TEXT , value = f'{ jobs_available [posting_num ]} ' ).click ()
50
+ time .sleep (2 )
51
+ driver .find_element (by = By .CLASS_NAME , value = "jobs-s-apply" ).click ()
52
+ finally :
53
+ jobs_available .remove (jobs_available [posting_num ])
54
+ try :
55
+ time .sleep (3 )
56
+ driver .find_element (by = By .CSS_SELECTOR , value = '[aria-label="Continue to next step"]' ).click ()
57
+ time .sleep (3 )
58
+ driver .find_element (by = By .CSS_SELECTOR , value = '[aria-label="Continue to next step"]' ).click ()
59
+ time .sleep (15 )
60
+ driver .find_element (by = By .CSS_SELECTOR , value = '[aria-label="Review your application"]' ).click ()
61
+ time .sleep (3 )
62
+ driver .find_element (by = By .CSS_SELECTOR , value = '[aria-label="Submit application"]' ).click ()
63
+ except NoSuchElementException :
64
+ print ('Cannot apply, skipped' )
65
+ print ("Work complete" )
0 commit comments