Skip to main content

Python package to automate activities on LinkedIn.

Project description

AutoLinkedIn

Elevate your LinkedIn game with AutoLinkedIn, a Python package designed for automating routine LinkedIn tasks. Whether you want to connect with specific users, manage connection requests, or optimize your LinkedIn networking, this package has you covered.

Key Features

  • Login to LinkedIn: Seamlessly access your LinkedIn account.
  • Send Connection Requests: Customize your connection requests by filtering users based on mutual connections, user types, and more.
  • Accept Connection Requests: Simplify the process of accepting incoming connection requests.
  • Delete/Withdraw Sent Requests: Keep your connection list clean by removing outdated sent requests.
  • Smart Follow-Unfollow: Automatically manage connections, delete aged requests, and maximize your daily interactions within LinkedIn's limits.
  • Background Mode: Run all tasks in the background mode without interfering with your regular work.
  • Search: Search for people.

Getting Started

To get started with AutoLinkedIn, first, install the package from PyPi using the following command:

pip install autolinkedin

Next, you can run and test the package by creating a script similar to autolinkedin/scripts/sample_script.py. Start by running your script with headless=False to ensure everything works as expected. Once you're confident, switch to headless=True to run your script in the background.

Here's a simplified example of running AutoLinkedIn:

from autolinkedin.linkedin import LinkedIn


with LinkedIn(
        username="<username/email>",
        password="<pas$word>",
        browser="<Chrome/Firefox>",
        headless="<True/False>",
) as ln:
    # Perform LinkedIn actions here
    ln.withdraw_sent_invitations(older_than_days=14)
    last_week_invitations = ln.count_invitations_sent_last_week()

    ln.send_invitations(
        max_invitations=max(ln.WEEKLY_MAX_INVITATION - last_week_invitations, 0),
        min_mutual=10,
        max_mutual=450,
        preferred_users=["Quant", "Software"],  # file_path or list of features
        not_preferred_users=["Sportsman", "Doctor"],  # file_path or list of features
        view_profile=True,  # (recommended) view profile of users you sent connection requests to
    )

    ln.accept_invitations()

    # Customize your actions as needed
    # ...

    # Alternatively, use the smart follow-unfollow method for a streamlined approach
    ln.smart_follow_unfollow(
        min_mutual=0,
        max_mutual=500,
        withdraw_invite_older_than_days=14,
        max_invitations_to_send=0,
        users_preferred=["Quant"],  # file_path or list of features
        users_not_preferred=["Sportsman"],  # file_path or list of features
        remove_recommendations=True, # remove recommendations which do not match criteria
    )

    # Additional method
    ln.remove_recommendations(min_mutual=10, max_mutual=500)

    # Search for people
    ln.search_people("Microsoft Recruiter")

Command Line Usage

AutoLinkedIn provides a convenient command-line interface for easy interaction. You can execute tasks directly from the command line with options like:

python -m autolinkedin -h

This command will display a list of available options, allowing you to configure and execute LinkedIn tasks without writing scripts.

> python -m autolinkedin -h
usage: autolinkedin [-h] [--env ENV] [--email EMAIL] [--password PASSWORD] [--browser BROWSER] [--headless] [--maxinvite MAXINVITE] [--minmutual MINMUTUAL] [--maxmutual MAXMUTUAL] [--withdrawdays WITHDRAWDAYS]
                   [--preferred PREFERRED] [--notpreferred NOTPREFERRED] [--cronfile CRONFILE] [--cronuser CRONUSER] [--rmcron | --no-rmcron] [--cronhour CRONHOUR]

options:
  -h, --help            show this help message and exit
  --env ENV             Linkedin environment file
  --email EMAIL         Email of LinkedIn user
  --password PASSWORD   Password of LinkedIn user
  --browser BROWSER     Browser used for LinkedIn
  --headless            Whether to run headless (i.e. without the browser visible in the front.)
  --maxinvite MAXINVITE
                        Maximum number of invitations to send
  --minmutual MINMUTUAL
                        Minimum number of mutual connections required.
  --maxmutual MAXMUTUAL
                        Maximum number of mutual connections required.
  --withdrawdays WITHDRAWDAYS
                        Withdraw invites older than this many days
  --preferred PREFERRED
                        Path to file containing preferred users characteristics
  --notpreferred NOTPREFERRED
                        Path to file containing characteristics of not preferred users
  --cronfile CRONFILE   Path to cronfile
  --cronuser CRONUSER   Name of user setting cron on the machine (needed by most OS)
  --rmcron, --no-rmcron
                        Whether to remove existing crons.
  --cronhour CRONHOUR   hour of the day you want to set cron for each day.

Setting Up Cron Jobs

To schedule recurring tasks, you can set up cron jobs using AutoLinkedIn. Here's how:

  1. Start with the following commands. (Use example.env as a reference while setting .env values)
python -m autolinkedin --env .env
  1. You can supply --rmcron to remove existing cron jobs:
python -m autolinkedin --rmcron --cronuser osuser
  1. To create a new cron job, specify the desired settings:
python -m autolinkedin --cronfile .cron.env --cronuser osuser --cronhour 23

These cron jobs enable you to automate your LinkedIn tasks at specific times, enhancing your networking efficiency.

Extras

AutoLinkedIn heavily relies on another package I authored named SeleniumTabs. Feel free to explore that package for additional functionality.

example.env

LINKEDIN_USER=
LINKEDIN_PASSWORD=
LINKEDIN_BROWSER=Chrome
LINKEDIN_BROWSER_HEADLESS=1
LINKEDIN_PREFERRED_USER=data/users_preferred.txt
LINKEDIN_NOT_PREFERRED_USER=data/users_not_preferred.txt
LINKEDIN_MIN_MUTUAL=0
LINKEDIN_MAX_MUTUAL=500
LINKEDIN_MAX_INVITE=0
LINKEDIN_WITHDRAW_INVITE_BEFORE_DAYS=14

TODOs

  • Enhance documentation
  • Include comprehensive tests

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

autolinkedin-1.6.4.tar.gz (17.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

autolinkedin-1.6.4-py3-none-any.whl (18.9 kB view details)

Uploaded Python 3

File details

Details for the file autolinkedin-1.6.4.tar.gz.

File metadata

  • Download URL: autolinkedin-1.6.4.tar.gz
  • Upload date:
  • Size: 17.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.11.5 Darwin/21.6.0

File hashes

Hashes for autolinkedin-1.6.4.tar.gz
Algorithm Hash digest
SHA256 34f3e0f667f48a88d5602baac110de7f12e7b34f1e83d284ccc4ec61b9c5c592
MD5 3324b24539a18cfd2486b21f08c4bfcb
BLAKE2b-256 f8fe4742adcacd250f9d96e55674dfce14d9ed30e9686d90e1ac051377b75db2

See more details on using hashes here.

File details

Details for the file autolinkedin-1.6.4-py3-none-any.whl.

File metadata

  • Download URL: autolinkedin-1.6.4-py3-none-any.whl
  • Upload date:
  • Size: 18.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.11.5 Darwin/21.6.0

File hashes

Hashes for autolinkedin-1.6.4-py3-none-any.whl
Algorithm Hash digest
SHA256 8fd320abc8b2e8e23605307b795b60d07b222d0c162b5ea864d3137d3e48f7f5
MD5 f8d10db838b48894db4e07b5009e0db8
BLAKE2b-256 29a372cd09e5e86b58acb0ce8a747e30c924eb7a56bb62847da2190034b88086

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page