diff --git a/Linkedin_ConnectingBot.py b/Linkedin_ConnectingBot.py index 97dbc95..8c93b03 100644 --- a/Linkedin_ConnectingBot.py +++ b/Linkedin_ConnectingBot.py @@ -1,34 +1,35 @@ from selenium import webdriver +from selenium.webdriver.common.by import By import time -driver = webdriver.Chrome('C:/Users/Mariya/chromedriver.exe') +driver = webdriver.Chrome() driver.get('https://www.linkedin.com') time.sleep(2) #********** LOG IN ************* -username = driver.find_element_by_xpath("//input[@name='session_key']") -password = driver.find_element_by_xpath("//input[@name='session_password']") +username = driver.find_element("xpath","//input[@name='session_key']") +password = driver.find_element("xpath","//input[@name='session_password']") username.send_keys('my_username') password.send_keys('my_password') time.sleep(2) -submit = driver.find_element_by_xpath("//button[@type='submit']").click() +submit = driver.find_element("xpath","//button[@type='submit']").click() #***************** ADD CONTACTS *********************** driver.get("https://www.linkedin.com/search/results/people/?network=%5B%22S%22%5D&origin=FACETED_SEARCH&page=10") time.sleep(2) -all_buttons = driver.find_elements_by_tag_name("button") +all_buttons = driver.find_elements(By.TAG_NAME,"button") connect_buttons = [btn for btn in all_buttons if btn.text == "Connect"] for btn in connect_buttons: driver.execute_script("arguments[0].click();", btn) time.sleep(2) - send = driver.find_element_by_xpath("//button[@aria-label='Send now']") + send = driver.find_element("xpath","//button[@aria-label='Send now']") driver.execute_script("arguments[0].click();", send) - close = driver.find_element_by_xpath("//button[@aria-label='Dismiss']") + close = driver.find_element("xpath","//button[@aria-label='Dismiss']") driver.execute_script("arguments[0].click();", close) - time.sleep(2) + time.sleep(2) \ No newline at end of file