-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLinkedIn_employ_Data_collect_from_company name.py
176 lines (109 loc) · 5.25 KB
/
LinkedIn_employ_Data_collect_from_company name.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
import pandas as pd
import numpy as np
from time import sleep
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from bs4 import BeautifulSoup as bs
"""
logging into the linked in profile
"""
username = "abhishekmahala28@gmail.com"
password = input()
driver = webdriver.Chrome('C:/Users/Abhishek Choudhary/.spyder-py3/chromedriver.exe')
driver.get("https://www.linkedin.com/")
username_input = driver.find_element_by_css_selector("input[name = 'session_key']")
password_input = driver.find_element_by_css_selector("input[name='session_password']")
username_input.send_keys(username)
password_input.send_keys(password)
login_button = driver.find_element_by_xpath("//button[@type='submit']")
login_button.click()
"""
reading the company data from the spreadsheet
"""
Data = pd.read_csv("Vaccine_Data.csv")
Data = np.array(Data.iloc[:,:].values)
df = []
for i in range (1, len(Data), 2) :
try :
Name_of_company = Data[i][1]
Link_of_company = Data[i][3]
"""
now going to the company page
"""
driver.get(Link_of_company)
search_parameter1 = "&origin=FACETED_SEARCH&title=manager"
search_parameter2 = "&origin=FACETED_SEARCH&title=Chief"
sleep(2)
source = driver.page_source
data=bs(source, 'html.parser')
data = data.find('div', class_ = "display-flex mt2 mb1")
data = data.find('a')
link = data.get('href')
link = "https://www.linkedin.com" + link
link_of_people_data = link.split("&")
link = link_of_people_data[0] + search_parameter1
"""
now going to the companys people according to the searchrequirements
"""
try :
driver.get(link)
sleep(2)
data = bs(driver.page_source, 'html.parser')
data = data.find_all('li', class_ = "reusable-search__result-container")
print(len(data))
#print(data[1].prettify())
for i in range (len(data)) :
item = data[i]
try :
try :
item_data = item.find('span', class_ = "visually-hidden").text.split()
name = ""
for i in range (1, len(item_data)-1) :
name += item_data[i] + " "
name = name[:-3]
except :
name = "out of network"
#print("name : ", name)
link_of_person = item.find('a').get('href')
job_destination = item.find('div', class_ = "entity-result__primary-subtitle t-14 t-black").text
ans = [name, Name_of_company, job_destination, Link_of_company, link_of_person ]
df.append(ans)
except :
print(i)
"""
for search parameter 2
"""
link = link_of_people_data[0] + search_parameter2
"""
now going to the companys people according to the searchrequirements
"""
driver.get(link)
sleep(2)
data = bs(driver.page_source, 'html.parser')
data = data.find_all('li', class_ = "reusable-search__result-container")
print(len(data))
#print(data[1].prettify())
for i in range (len(data)) :
item = data[i]
try :
try :
item_data = item.find('span', class_ = "visually-hidden").text.split()
name = ""
for i in range (1, len(item_data)-1) :
name += item_data[i] + " "
name = name[:-3]
except :
name = "out of network"
link_of_person = item.find('a').get('href')
job_destination = item.find('div', class_ = "entity-result__primary-subtitle t-14 t-black").text
ans = [name, Name_of_company, job_destination, Link_of_company, link_of_person ]
df.append(ans)
except :
print(i)
except :
pass
except :
pass
#df_intial = pd.read_csv("result.csv")
df = pd.DataFrame(df, columns= ['name_of_person', 'name_of_company', 'job', 'link_of_company', 'linh_of_person'])
df.to_csv("result.csv")