Send invitations to post commenters
Tags: #linkedin #post #comments #invitations #connections #naas_drivers #content #snippet #dataframe
Last update: 2023-05-29 (Created: 2022-07-17)
Description: This notebook allows users to quickly and easily send LinkedIn invitations to people who have commented on their posts.
Disclaimer:
This code is in no way affiliated with, authorized, maintained, sponsored or endorsed by Linkedin or any of its affiliates or subsidiaries. It uses an independent and unofficial API. Use at your own risk.
This project violates Linkedin's User Agreement Section 8.2, and because of this, Linkedin may (and will) temporarily or permanently ban your account. We are not responsible for your account being banned.
from naas_drivers import linkedin
import naas
import time
LI_AT = (
naas.secret.get("LI_AT") or "ENTER_YOUR_COOKIE_LI_AT_HERE"
) # EXAMPLE AQFAzQN_PLPR4wAAAXc-FCKmgiMit5FLdY1af3-2
JSESSIONID = (
naas.secret.get("JSESSIONID") or "ENTER_YOUR_COOKIE_JSESSIONID_HERE"
) # EXAMPLE ajax:8379907400220387585
To get the URL for a post, click on the three dots option to the right corner of that post on LinkedIn and select "copy link to post" option.
Replace the string 'URL' below with the actual URL
POST_URL = "URL"
Running the below cell fetches the information related to all the comments of the post and stores the information in a dataframe
df = linkedin.connect(LI_AT, JSESSIONID).post.get_comments(POST_URL)
profiles = df["PROFILE_URL"] # storing the profile URLs of all the commenters
filtered_profiles = []
for i in profiles:
distance = linkedin.profile.get_network(profile_url=i)["DISTANCE"]
if distance[0] != "DISTANCE_1":
filtered_profiles.append(i)
time.sleep(3)
for i in filtered_profiles: # looping through each commenter's profile URL
linkedin.connect(LI_AT, JSESSIONID).invitation.send(
recipient_url=i
) # send invitation
Last modified 1mo ago