-
Notifications
You must be signed in to change notification settings - Fork 0
/
auto_linkedin.py
57 lines (49 loc) · 1.94 KB
/
auto_linkedin.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
55
56
57
from time import sleep
from traceback import print_exc
from selenium import webdriver
from selenium import common
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from AutoLogin import lib
import post
import share
lib.PSEC = input("Insert the path of the your passwords file: ").replace("/", "\\")
def main():
print("What do you want to do?:\n")
print(" 1)Post all content in posts")
print(" 2)Share all content in shares")
print("\n:> ", end='')
mode = int(input())
browser = webdriver.Chrome(executable_path=input("Insert the path of the chrome driver for Selenium: ").replace("/", "\\"))
try:
if mode != 1 and mode != 2:
raise ValueError("Invalid option selected")
email = lib.find_data(lib.PSEC, "linkedin", lib.EPATTERN)
password = lib.find_data(lib.PSEC, "linkedin", lib.PPATTERN)
url = lib.find_field("linkedin", "url")
email_xpath = lib.find_field("linkedin", "email_xpath")
password_xpath = lib.find_field("linkedin", "password_xpath")
submit_xpath = lib.find_field("linkedin", "submit_xpath_1")
try:
browser.get(url)
browser.find_element_by_xpath(email_xpath).send_keys(email)
browser.find_element_by_xpath(password_xpath).send_keys(password)
if mode == 1:
post.post(browser)
else:
share.share(browser)
except common.exceptions.NoSuchElementException:
print_exc()
except common.exceptions.TimeoutException:
print("Something went wrong during finding a clickable element")
print_exc()
except ValueError:
print_exc()
except:
print_exc()
sleep(30)
finally:
browser.quit()
if __name__ == "__main__":
main()