-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlinkedinbot.py
37 lines (30 loc) · 1.22 KB
/
linkedinbot.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
from selenium import webdriver
import pyautogui as pag
import time
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.keys import Keys
driver = webdriver.Chrome('/Users/aryaarun/Downloads/chromedriver')
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('your_mailid')
password.send_keys('your_password')
time.sleep(2)
submit = driver.find_element_by_xpath("//button[@type='submit']").click()
#connecting
driver.get(
"url of the page you want to connect to")
time.sleep(2)
all_buttons=driver.find_elements_by_tag_name("button")
connect_buttons = [btn for btn in all_buttons if btn.text == 'Connect']
time.sleep(2)
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)