|
| 1 | +from selenium import webdriver |
| 2 | +from selenium.webdriver.common.keys import Keys |
| 3 | +from selenium.common.exceptions import NoSuchElementException |
| 4 | +import time |
| 5 | + |
| 6 | +ACCOUNT_EMAIL = "pysmpt15@gmail.com" |
| 7 | +ACCOUNT_PASSWORD = "123456Ab" |
| 8 | +chrome_driver_path = "/Users/fahadsmacbook/Downloads/Python 100 Days/Development/chromedriver" |
| 9 | + |
| 10 | +driver = webdriver.Chrome(executable_path=chrome_driver_path) |
| 11 | +driver.get("https://www.linkedin.com/jobs/search/?f_LF=f_AL&geoId=102257491&keywords=marketing%20intern&location=London%2C%20England%2C%20United%20Kingdom&redirect=false&position=1&pageNum=0") |
| 12 | + |
| 13 | + |
| 14 | +sign_in_button = driver.find_element_by_link_text("Sign in") |
| 15 | +sign_in_button.click() |
| 16 | + |
| 17 | + |
| 18 | +email_field = driver.find_element_by_id("username") |
| 19 | +email_field.send_keys(ACCOUNT_EMAIL) |
| 20 | +password_field = driver.find_element_by_id("password") |
| 21 | +password_field.send_keys(ACCOUNT_PASSWORD) |
| 22 | +password_field.send_keys(Keys.ENTER) |
| 23 | + |
| 24 | + |
| 25 | + |
| 26 | + |
| 27 | +jobs = driver.find_elements_by_css_selector(".job-card-container--clickable") |
| 28 | +for job in jobs : |
| 29 | + job.click() |
| 30 | + try : |
| 31 | + apply_button = driver.find_element_by_css_selector(".jobs-s-apply button") |
| 32 | + apply_button.click() |
| 33 | + mbl = driver.find_element_by_css_selector(".fb-single-line-text__input") |
| 34 | + mbl.send_keys("9293038523") |
| 35 | + submit_button = driver.find_element_by_css_selector("footer button") |
| 36 | + |
| 37 | + # If the submit_button is a "Next" button, then this is a multi-step application, so skip. |
| 38 | + if submit_button.get_attribute("data-control-name") == "continue_unify": |
| 39 | + close_button = driver.find_element_by_class_name("artdeco-modal__dismiss") |
| 40 | + close_button.click() |
| 41 | + time.sleep(2) |
| 42 | + discard_button = driver.find_element_by_css_selector(".artdeco-modal__confirm-dialog-btn .artdeco-button") |
| 43 | + discard_button.click() |
| 44 | + print("Complex application, skipped.") |
| 45 | + continue |
| 46 | + else: |
| 47 | + submit_button.click() |
| 48 | + |
| 49 | + # Once application completed, close the pop-up window. |
| 50 | + time.sleep(2) |
| 51 | + close_button = driver.find_element_by_class_name("artdeco-modal__dismiss") |
| 52 | + close_button.click() |
| 53 | + |
| 54 | + except : |
| 55 | + print("No apply button found") |
| 56 | + |
0 commit comments