forked from tomquirk/linkedin-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gptshowcase.py
54 lines (43 loc) · 1.71 KB
/
gptshowcase.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import time
def login_to_linkedin(driver, username, password):
driver.get("https://www.linkedin.com/login")
driver.find_element(By.ID, "username").send_keys(username)
driver.find_element(By.ID, "password").send_keys(password)
driver.find_element(By.CSS_SELECTOR, ".btn__primary--large").click()
def search_for_profiles(driver, keyword):
search_box = driver.find_element(
By.CSS_SELECTOR, "input[type='text'][aria-label='Search']"
)
search_box.send_keys(keyword)
search_box.send_keys(Keys.RETURN)
def navigate_to_profiles_and_invite(driver):
profile_cards = driver.find_elements(By.CLASS_NAME, "entity-result__item")
for card in profile_cards:
try:
card.click()
WebDriverWait(driver, 10).until(
EC.presence_of_element_located(
(By.CSS_SELECTOR, ".pv-s-profile-actions")
)
)
invite_button = driver.find_element(
By.CSS_SELECTOR, ".pv-s-profile-actions"
)
invite_button.click()
driver.find_element(By.CSS_SELECTOR, ".artdeco-button--primary").click()
except:
pass
driver.back()
if __name__ == "__main__":
driver = webdriver.Chrome()
login_to_linkedin(driver, "[email protected]", "canadaconan17")
time.sleep(2)
search_for_profiles(driver, "Software Developer")
time.sleep(2)
navigate_to_profiles_and_invite(driver)
driver.quit()