Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
daniel421
MyOwnPentestToolsByAGS
Commits
096958fb
Commit
096958fb
authored
Nov 29, 2021
by
Your Name
Browse files
Selenium Linkedin improved
parent
cbfb130f
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
geckodriver.log
View file @
096958fb
This diff is collapsed.
Click to expand it.
selenium_black_box_discover_linkedin.py
View file @
096958fb
...
...
@@ -43,7 +43,7 @@ def wait_element_by_xpath(browser, xpath):
counter
=
60
while
not
is_element_available
:
try
:
search
=
browser
.
wait
_element_by_xpath
(
browser
,
xpath
)
search
=
browser
.
find
_element_by_xpath
(
xpath
)
is_bar_search_available
=
True
print
(
"found"
)
return
search
...
...
@@ -61,7 +61,7 @@ def make_a_linkedin_request(browser, query):
is_bar_search_available
=
False
while
not
is_bar_search_available
:
try
:
search
=
element_by_xpath
(
'/html/body/div[7]/header/div/div/div/div[1]/input'
)
search
=
element_by_xpath
(
'/
/
html/body/div[7]/header/div/div/div/div[1]/input'
)
search
.
send_keys
(
query
)
search
.
send_keys
(
Keys
.
RETURN
)
is_bar_search_available
=
True
...
...
@@ -83,8 +83,9 @@ def login_to_linkedin(browser, username_linkedin, password_linkedin):
def
extract_employee_from_enterprise
(
browser
,
url_linkedin
):
dictionary_users
=
{}
browser
.
get
(
url_linkedin
)
search
=
wait_element_by_xpath
(
browser
,
'/html/body/div[7]/div[3]/div/div[2]/div/div[2]/main/div[1]/section/div/div[2]/div[1]/div[2]/div/a[2]/span'
)
browser
.
get
(
url_linkedin
+
'/people/'
)
time
.
sleep
(
3
)
search
=
wait_element_by_xpath
(
browser
,
'//html/body/div[6]/div[3]/div/div[2]/div/div[2]/main/div[1]/section/div/div[2]/div[1]/div[2]/div/a[2]/span'
)
search
.
click
()
time
.
sleep
(
2
)
# Max page number to review
...
...
@@ -129,26 +130,30 @@ def go_to_linkedin(browser, is_cookie_consent_clicked):
while
not
is_cookie_consent_clicked
:
print
(
"cookie consent"
)
try
:
browser
.
find_element_by_xpath
(
'/html/body/div[1]/div/section/div/div[2]/button[2]'
).
click
()
browser
.
find_element_by_xpath
(
'/
/
html/body/div[1]/div/section/div/div[2]/button[2]'
).
click
()
is_cookie_consent_clicked
=
True
except
:
is_cookie_consent_clicked
=
False
time
.
sleep
(
1
)
return
links
def
find_element_by_innerText
(
browser
,
url
,
innerText
,
tag
):
browser
.
get
(
url
)
time
.
sleep
(
3
)
for
e
in
browser
.
find_elements_by_tag_name
(
tag
):
try
:
if
innertText
==
e
.
get_attribute
(
'innerText'
):
return
e
except
:
pass
def
get_contact_details
(
browser
,
url
):
browser
.
get
(
url
)
time
.
sleep
(
5
)
for
b
in
browser
.
find_elements_by_tag_name
(
"a"
):
try
:
if
b
.
get_attribute
(
'innerText'
)
==
"Coordonnées"
:
b
.
click
()
except
:
pass
full_name
=
browser
.
wait_element_by_xpath
(
browser
,
'/html/body/div[5]/div[3]/div/div/div/div/div[3]/div/div/main/div/section/div[2]/div[2]/div[1]/div[1]/h1'
).
innerText
full_name
=
browser
.
find_element_by_tag_name
(
'h1'
).
get_property
(
'innerText'
)
print
(
"Getting details of: "
+
full_name
)
browser
.
find_element_by_xpath
(
"//*[text()='Coordonnées']"
).
click
()
print
(
url
)
list_ressources
=
browser
.
find_elements_by_class_name
(
"pv-contact-info"
)
for
r
in
list_ressources
:
...
...
@@ -163,6 +168,7 @@ def get_contact_details(browser, url):
# get_contact_details(browser=browser, url='https://www.linkedin.com/in/ba-assanatou/')
if
__name__
==
"__main__"
:
url
=
sys
.
argv
[
1
]
binary
=
FirefoxBinary
(
'/usr/bin/firefox'
)
browser
=
webdriver
.
Firefox
(
service
=
serv
,
proxy
=
proxy
,
options
=
options
)
go_to_linkedin
(
browser
=
browser
,
is_cookie_consent_clicked
=
False
)
...
...
@@ -170,12 +176,10 @@ if __name__ == "__main__":
login_to_linkedin
(
browser
=
browser
,
username_linkedin
=
username_linkedin
,
password_linkedin
=
password_linkedin
)
#make_a_linkedin_request(browser=browser,query="quodagis")
users_dict
=
{}
users_dict
=
extract_employee_from_enterprise
(
browser
=
browser
,
url_linkedin
=
'https://www.linkedin.com/company/quodagis/'
)
time
.
sleep
(
4
)
users_dict
=
extract_employee_from_enterprise
(
browser
=
browser
,
url_linkedin
=
url
)
print
(
users_dict
)
for
url
in
users_dict
:
get_contact_details
(
browser
=
browser
,
url
=
url
)
browser
.
quit
()
# Get the name of the person
#/html/body/div[5]/div[3]/div/div/div/div/div[3]/div/div/main/div/section/div[2]/div[2]/div[1]/div[1]/h1
#bowser.quit()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment