Create contacts from linkedin post likes
Tags: #hubspot #crm #sales #contact #naas_drivers #linkedin #post #contact
Author: Florent Ravenel

Input

Import librairies

1
from naas_drivers import linkedin, hubspot
2
import naas
3
import requests
Copied!

Setup your HubSpot

👉 Access your HubSpot API key
1
HS_API_KEY = 'YOUR_HUBSPOT_API_KEY'
Copied!

Setup your LinkedIn

1
# Coookies
2
LI_AT = "AQFAzQN_PLPR4wAAAXc-FCKmgiMit5FLdY1af3-2AQFAzQN_PLPR4wAAAXc-FCKmgiMit5FLdY1af3-2" # EXAMPLE AQFAzQN_PLPR4wAAAXc-FCKmgiMit5FLdY1af3-2
3
JSESSIONID = "ajax:837990740022038xxxxx" # EXAMPLE ajax:8379907400220387585
4
5
# Post URL
6
POST_URL = "----"
Copied!

Model

Get post likes

1
df_posts = linkedin.connect(LI_AT, JSESSIONID).post.get_likes(POST_URL)
2
3
# Display the number of likes
4
print("Number of likes: ", df_posts.PROFILE_URN.count())
Copied!
1
# Show dataframe with list of profiles from likes
2
df_posts
Copied!

Create contacts from LinkedIn post likes

1
def create_contacts_from_post(df,
2
c_profile_urn="PROFILE_URN",
3
c_firstname="FIRSTNAME",
4
c_lastname="LASTNAME",
5
c_occupation="OCCUPATION"):
6
for _, row in df.iterrows():
7
profile_urn = row[c_profile_urn]
8
firstname = row[c_firstname]
9
lastname = row[c_lastname]
10
occupation = row[c_occupation]
11
linkedinbio = f"https://www.linkedin.com/in/{profile_urn}"
12
email = None
13
phone = None
14
15
# contact
16
try:
17
contact = linkedin.connect(LI_AT, JSESSIONID).profile.get_contact(linkedinbio)
18
email = contact.loc[0, "EMAIL"]
19
phone = contact.loc[0, "PHONENUMBER"]
20
except:
21
print("No contact info")
22
23
# With send method
24
data = {"properties":
25
{
26
"linkedinbio": linkedinbio,
27
"firstname": firstname,
28
"lastname": lastname,
29
"jobtitle": occupation,
30
"email": email,
31
"phone": phone,
32
}
33
}
34
print(data)
35
hubspot.connect(HS_API_KEY).contacts.send(data)
Copied!

Output

Display result

1
create_contacts_from_post(df_posts)
Copied!
Copy link
Edit on GitHub