-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
70 lines (57 loc) · 2.44 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
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.common.by import By
import time
ACCOUNT_EMAIL = "EMAIL"
ACCOUNT_PASSWORD = "PASSWORD"
PHONE = "PHONENUMBER"
def abort_application():
# click Close Button
close_button = driver.find_element(by=By.CLASS_NAME, value="artdeco-modal__dismiss")
close_button.click()
time.sleep(2)
# click Discard Button
discard_button = driver.find_elements(by=By.CLASS_NAME, value="artdeco-modal__confirm-dialog-btn")[1]
discard_button.click()
# keep the browser open if the script crashes.
chrome_options = webdriver.ChromeOptions()
chrome_options.add_experimental_option("detach", True)
driver = webdriver.Chrome(options=chrome_options)
#https://www.linkedin.com/jobs/search/?currentJobId=3787364026&f_AL=true&f_E=2&geoId=90000070&keywords=software%20engineer&location=New%20York%20City%20Metropolitan%20Area&origin=JOB_SEARCH_PAGE_SEARCH_BUTTON&refresh=true
driver.get(
"https://www.linkedin.com/jobs/search/?currentJobId=3787364026&f_AL=true&f_E=2&geoId=90000070"
"&keywords=software%20engineer"
"&location=New%20York%20City%20Metropolitan%20Area"
"&origin=JOB_SEARCH_PAGE_SEARCH_BUTTON"
"&redirect=false&position=1&pageNum=0"
)
# Reject Cookies
time.sleep(2)
reject_button = driver.find_element(by=By.CSS_SELECTOR, value='button[action-type="DENY"]')
reject_button.click()
# Click Sign in Button
time.sleep(2)
sign_in_button = driver.find_element(by=By.LINK_TEXT, value=" Sign in ")
sign_in_button.click()
# Sign in
time.sleep(5)
email_field = driver.find_element(by=By.ID, value="username")
email_field.send_keys(ACCOUNT_EMAIL)
password_field = driver.find_element(by=By.ID, value="password")
password_field.send_keys(ACCOUNT_PASSWORD)
password_field.send_keys(Keys.ENTER)
# You may be presented with a CAPTCHA - Solve the Puzzle Manually
input("Press Enter when you have solved the Captcha")
#Locate the apply button
time.sleep(5)
apply_button = driver.find_element(by=By.CSS_SELECTOR, value=".jobs-s-apply button")
apply_button.click()
#If application requires phone number and the field is empty, then fill in the number.
time.sleep(5)
phone = driver.find_element(by=By.CSS_SELECTOR, value="input[id*=phoneNumber]")
if phone.text == "":
phone.send_keys(PHONE)
#Submit the application
submit_button = driver.find_element(by=By.CSS_SELECTOR, value="footer button")
submit_button.click()