-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathLinkedin_ConnectingBot.py
34 lines (25 loc) · 1.21 KB
/
Linkedin_ConnectingBot.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
from selenium import webdriver
import time
driver = webdriver.Chrome('C:/Users/Mariya/chromedriver.exe')
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.send_keys('my_username')
password.send_keys('my_password')
time.sleep(2)
submit = driver.find_element_by_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")
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']")
driver.execute_script("arguments[0].click();", send)
close = driver.find_element_by_xpath("//button[@aria-label='Dismiss']")
driver.execute_script("arguments[0].click();", close)
time.sleep(2)