-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsendInvite.py
More file actions
52 lines (39 loc) · 2.11 KB
/
sendInvite.py
File metadata and controls
52 lines (39 loc) · 2.11 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
# Function to send connection invite with personalized note
def sendInvite(profile, note_template):
# Extract first name from profile
first_name = profile['first_name']
# Replace placeholder with first name in the note template
personalized_note = note_template.replace('{first_name}', first_name)
# Extract LinkedIn profile URL
# profile_url = profile['profile_url']
profile_url = 'https://www.linkedin.com/in/tomsunil'
driver = webdriver.Chrome()
driver.get(profile_url)
# try:
# # Open LinkedIn profile URL
# driver.get(profile_url)
# # Click on the "login" button
# connect_button = WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, "//button[contains(text(), 'Sign in')]")))
# connect_button.click()
# # Click on the "Connect" button
# connect_button = WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, "//button[contains(text(), 'Connect')]")))
# connect_button.click()
# # Click on "Add a note"
# add_note_button = WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, "//button[contains(text(), 'Add a note')]")))
# add_note_button.click()
# # Input personalized note
# note_input = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, "//textarea[@name='message']")))
# note_input.send_keys(personalized_note)
# # Click on the "Send now" button
# send_button = WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, "//button[contains(text(), 'Send now')]")))
# send_button.click()
# print(f"Invite sent to {first_name} with personalized note.")
# except Exception as e:
# print(f"Error sending invite to: {str(e)}")
# finally:
# # Close the WebDriver
# driver.quit()