-
-
Notifications
You must be signed in to change notification settings - Fork 42
/
test.py
90 lines (72 loc) · 2.72 KB
/
test.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
import os,time,sys
from selenium import webdriver
from selenium.webdriver.firefox.options import Options
from utils import prGreen,prRed,prYellow
prYellow("ℹ️ This script will check if the bot can automatically log in Linkedin for you.")
def checkPython():
try:
if(sys.version):
prGreen("✅ Python is succesfully installed!")
else:
prRed("❌ Python is not installed please install Python first: https://www.python.org/downloads/")
except Exception as e:
prRed(e)
def checkPip():
try:
import pip
prGreen("✅ Pip is succesfully installed!")
except ImportError:
prRed("❌ Pip not present. Install pip: https://pip.pypa.io/en/stable/installation/")
def checkSelenium():
try:
import selenium
prGreen("✅ Selenium is succesfully installed!")
except ImportError:
prRed("❌ Selenium not present. Install Selenium: https://pypi.org/project/selenium/")
def checkFirefox():
try:
import subprocess
output = subprocess.check_output(['firefox', '--version'])
if(output):
prGreen("✅ Firefox is succesfully installed!")
else:
prRed("❌ Firefox not present. Install firefox: https://www.mozilla.org/en-US/firefox/")
except ImportError as e:
prRed(e)
def checkSeleniumLinkedin():
options = Options()
#firefoxProfileRootDir = os.getenv('firefoxProfileRootDir')
options.add_argument("--start-maximized")
options.add_argument("--ignore-certificate-errors")
options.add_argument('--no-sandbox')
options.add_argument("--disable-extensions")
options.add_argument("--disable-blink-features")
options.add_argument("--disable-blink-features=AutomationControlled")
#options.add_argument("-profile")
#options.add_argument(firefoxProfileRootDir)
#options.headless = True
browser = webdriver.Firefox(options=options)
try:
browser.get('https://www.ongundemirag.com')
if(browser.title.index("Ongun")>-1):
prGreen("✅ Selenium and geckodriver is working succesfully!")
else:
prRed("❌ Please check if Selenium and geckodriver is installed")
except Exception as e:
prRed(e)
try:
browser.get('https://www.linkedin.com/feed/')
time.sleep(3)
if "Feed" in browser.title:
prGreen('✅ Successfully you are logged in to Linkedin, you can now run main bot script!')
else:
prRed('❌ You are not automatically logged in, please set up your Firefox Account correctly.')
except Exception as e:
prRed(e)
finally:
browser.quit()
checkPython()
checkPip()
checkSelenium()
checkFirefox()
checkSeleniumLinkedin()