-
Notifications
You must be signed in to change notification settings - Fork 173
/
Copy pathmain.py
65 lines (51 loc) · 2.09 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
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.common.exceptions import NoSuchElementException
import time
ACCOUNT_EMAIL = YOUR LOGIN EMAIL
ACCOUNT_PASSWORD = YOUR LOGIN PASSWORD
PHONE = YOUR PHONE NUMBER
chrome_driver_path = "/Users/lenargasimov/Development/chromedriver"
driver = webdriver.Chrome(chrome_driver_path)
driver.get("https://www.linkedin.com/jobs/search/?f_E=2&f_WRA=true&keywords=junior%20python%20developer")
time.sleep(2)
sign_in_button = driver.find_element_by_link_text("Sign in")
sign_in_button.click()
time.sleep(5)
email_field = driver.find_element_by_id("username")
email_field.send_keys(ACCOUNT_EMAIL)
password_field = driver.find_element_by_id("password")
password_field.send_keys(ACCOUNT_PASSWORD)
password_field.send_keys(Keys.ENTER)
time.sleep(5)
all_listings = driver.find_elements_by_css_selector(".job-card-container--clickable")
for listing in all_listings:
print("called")
listing.click()
time.sleep(2)
try:
apply_button = driver.find_element_by_css_selector(".jobs-s-apply button")
apply_button.click()
time.sleep(5)
phone = driver.find_element_by_class_name("fb-single-line-text__input")
if phone.text == "":
phone.send_keys(PHONE)
submit_button = driver.find_element_by_css_selector("footer button")
if submit_button.get_attribute("data-control-name") == "continue_unify":
close_button = driver.find_element_by_class_name("artdeco-modal__dismiss")
close_button.click()
time.sleep(2)
discard_button = driver.find_elements_by_class_name("artdeco-modal__confirm-dialog-btn")[1]
discard_button.click()
print("Complex application, skipped.")
continue
else:
submit_button.click()
time.sleep(2)
close_button = driver.find_element_by_class_name("artdeco-modal__dismiss")
close_button.click()
except NoSuchElementException:
print("No application button, skipped.")
continue
time.sleep(5)
driver.quit()