-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathstage3.py
87 lines (85 loc) · 3.99 KB
/
stage3.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
from dependencies import *
from login import *
import config
df = pd.read_csv("roles_of_person_in_pervious_list.csv")
df.drop_duplicates(keep=False, inplace=True)
arr = list(df['Company_Name'])
names = list(df['Name'])
hitWords = ['full-time', 'part-time', 'internship', 'contract', 'crio.Do', 'girlscript foundation', 'girlscript summer of code', 'google summer of code', 'major league hacking', 'placementunit|bitspilani',
'highcommissionofcanadainindia', 'australiandepartmentofhomeaffairs', 'googlesummerofcode', 'majorleaguehacking', 'australiandepartmentofhomeaffairs', 'highcommissionofcanadainindia', 'britishrirways', 'resumevogue']
blockWords = ['placement', 'university', 'bachleors', 'college', 'institute', 'jecrc', 'daiict', 'student', 'ieee', 'dtu', 'self-employed',
'self', 'iit', 'da-iict', 'army', 'school', 'corona', 'mit', 'harvard', 'freelancing', 'freelancer', 'freelance', 'youtuber']
people = set()
for j in range(len(arr)):
designation = " ".join(arr[j].split())
flag = False
if len(designation) > 12:
if designation[0:12].lower() == "company name":
flag = True
designation = designation.replace(designation[0:12], "")
if flag == False and len(designation) > 7:
if (designation[0:7].lower() == "company"):
designation = designation.replace(designation[:7], "")
designation = designation.lower().split()
checker = False
for i in range(len(designation)):
if designation[i] in blockWords:
checker = True
break
s = ""
if checker == False:
if (designation[-1] in hitWords):
designation = designation[:-1]
if " ".join(designation) not in hitWords:
people.add(" ".join(designation))
people = list(people)
count = 0
for j in range(len(people)):
if count > 99:
break
driver.get("https://www.linkedin.com/search/results/companies/?keywords=" +
str(people[j])+"&origin=GLOBAL_SEARCH_HEADER")
src = driver.page_source
parser = soup(src, "html.parser")
userList = parser.find_all(
"li", {"class": "reusable-search__result-container"})
if len(userList) != 0:
links = userList[0].a['href']+"/people/"
driver.get(links)
time.sleep(10)
src = driver.page_source
parser = soup(src, "html.parser")
time.sleep(4)
user = parser.find_all(
"li", {"class": "grid grid__col--lg-8 pt5 pr4 m0"})
count = 0
for i in range(len(user)):
count += 1
time.sleep(2)
src = driver.page_source
parser = soup(src, "html.parser")
WebDriverWait(driver, 1000)
try:
connectRequest = driver.find_element_by_xpath(
"//button[@class='artdeco-button artdeco-button--2 artdeco-button--secondary ember-view full-width']")
if connectRequest:
connectRequest = connectRequest.click()
addNote = driver.find_element_by_xpath(
"//button[@class='mr1 artdeco-button artdeco-button--muted artdeco-button--3 artdeco-button--secondary ember-view']")
time.sleep(1)
addNote.click()
message = driver.find_element_by_xpath(
"//textarea[@class='ember-text-area ember-view connect-button-send-invite__custom-message mb3']")
name = driver.find_element_by_xpath(
"//div[@class='org-people-profile-card__profile-title t-black lt-line-clamp lt-line-clamp--single-line ember-view']").text
print(name)
message.send_keys(config.message)
send = driver.find_element_by_xpath(
"//button[@class='ml1 artdeco-button artdeco-button--3 artdeco-button--primary ember-view']")
send.click()
else:
pass
except:
pass
else:
pass