-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlolkedin.py
98 lines (76 loc) · 3.74 KB
/
lolkedin.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
91
92
93
94
95
from selenium import webdriver as wd;
import sys, os;
import time;
import sys;
from selenium.common.exceptions import (ElementClickInterceptedException,
ElementNotInteractableException,
ElementNotSelectableException,
ElementNotVisibleException,
ErrorInResponseException,
InsecureCertificateException,
InvalidCoordinatesException,
InvalidElementStateException,
InvalidSessionIdException,
InvalidSelectorException,
ImeNotAvailableException,
ImeActivationFailedException,
InvalidArgumentException,
InvalidCookieDomainException,
JavascriptException,
MoveTargetOutOfBoundsException,
NoSuchCookieException,
NoSuchElementException,
NoSuchFrameException,
NoSuchWindowException,
NoAlertPresentException,
ScreenshotException,
SessionNotCreatedException,
StaleElementReferenceException,
TimeoutException,
UnableToSetCookieException,
UnexpectedAlertPresentException,
UnknownMethodException,
WebDriverException)
pagenumber = sys.argv[1] # arguments to pass - page number
extractor = 1; # extractor
#
# Press CTRL+C to stop the script
#
print ("Example of usage: \n")
print ("python lolkedin.py 22 pentest [email protected] B00bsterpassw0rd \n")
print ("First argument stands for page number you want to start, second one is keyword and login/password \n")
searchstring = sys.argv[2] # keyword
username = sys.argv[3] #
password = sys.argv[4] #
firefox = wd.Firefox ();
firefox.get ('https://linkedin.com/');
firefox.find_element_by_id ('login-email').send_keys (username);
firefox.find_element_by_id ('login-password').send_keys (password);
firefox.find_element_by_id ('login-submit').click ();
pagenumberint = int(pagenumber);
extractorint = int(extractor);
def findconnect (pagenumberint,extractorint):
firefox.get ('https://www.linkedin.com/search/results/people/?keywords='+str(searchstring)+'&origin=GLOBAL_SEARCH_HEADER&page='+str(pagenumberint)+'');
time.sleep(2)
firefox.execute_script("document.getElementsByClassName('search-result__actions--primary button-secondary-medium m5')["+str(extractorint)+"].click();")
time.sleep(2)
sendnow = firefox.find_element_by_css_selector(".button-primary-large.ml1")
firefox.execute_script("arguments[0].style.visibility = 'visible'; arguments[0].click();", sendnow)
time.sleep(2)
return
def fireball(pagenumberint,extractorint):
try:
while extractorint < 6:
findconnect(pagenumberint,extractorint);
if extractorint == 5:
extractorint = 0;
print ("we are here");
extractorint+=1
except (NoSuchElementException,JavascriptException):
print ("Navigating to another page #: "+str(pagenumberint)+"");
pagenumberint+=1
fireball(pagenumberint,1);
pass
return
fireball(pagenumberint,extractorint);
firefox.close();