Get profile posts stats
Tags: #linkedin #profile #post #stats #naas_drivers #content #automation #csv
Last update: 2023-08-23 (Created: 2022-06-30)
Description: This notebook fetches your profile's post statistics from LinkedIn and stores them in a CSV file.
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
Mandatory
li_at
: Cookie used to authenticate Members and API clients.JSESSIONID
: Cookie used for Cross Site Request Forgery (CSRF) protection and URL signature validation.linkedin_url
: This variable represents the LinkedIn company URL.
Optional
cron
: This variable represents the CRON syntax used to run the scheduler. More information here: https://crontab.guru/#0_12,18___1-5limit
: number of posts to be retrieved.file_path
: CSV file path to be saved in your local.
# Mandatory
li_at = naas.secret.get("LINKEDIN_LI_AT") or "YOUR_LINKEDIN_LI_AT" #example: AQFAzQN_PLPR4wAAAXc-FCKmgiMit5FLdY1af3-2
JSESSIONID = naas.secret.get("LINKEDIN_JSESSIONID") or "YOUR_LINKEDIN_JSESSIONID" #example: ajax:8379907400220387585
linkedin_url = "https://www.linkedin.com/in/xxxxx/" # EXAMPLE "https://www.linkedin.com/in/XXXXXX/"
# Optional
cron = "0 12,18 * * 1-5" #At minute 0 past hour 12 and 18 on every day-of-week from Monday through Friday.
limit = 5
file_path = f"LINKEDIN_PROFILE_POSTS.csv"
df = linkedin.connect(li_at, JSESSIONID).profile.get_posts_feed(linkedin_url, limit=limit)
print("Row fetched:", len(df))
df.head(1)
df.to_csv(file_path, index=False)
naas.scheduler.add(cron=cron)
# to de-schedule this notebook, simply run the following command:
# naas.scheduler.delete()
Last modified 29d ago