Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug fix #3

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions Linkedin_ConnectingBot.py
Original file line number Diff line number Diff line change
@@ -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)