Contents

TL;DR

The LinkedIn Bot automates sending connection requests and withdrawing pending requests on LinkedIn using Selenium. It finds users from companies/universities listed in orgs.csv, handles LinkedIn's security measures, respects connection limits, and sends errors with email notifications. The code can be found here

Features

Sending Connection

The Python code logs in and checks for app, code, and captcha verifications. If it detects any of these, it sends an email to the specified email address.

  • If a verification code is required, the tool sends a notification and waits for a response containing the code.
  • If app authorization is mandatory, it sends another email and waits for a "yes" or "no" response—a "yes" indicates that authorization has been granted through the phone app.
  • Finally, if a captcha is presented, the tool sends a screenshot of the captcha images and waits for a number between 1 and 6 that represents the correct image.

Once logged in, the tool clears all recently selected organizations (which resets every two months) from the loaded csv file and enters in a loop, in which it randomly selects an organization biased towards its row number (with higher row numbers having a greater probability to be selected). It then navigates to the organization's people page and begins sending connection requests to eligible individuals. It switches the organization to searching for connectable people once it finds a sufficient number of them (this threshold is configurable in the .env file).

The loop stops once the daily limit—randomly selected from a range of 15 to 24—is reached, or LinkedIn weekly one.

Withdrawing connection

After logging in as described above, it navigates to the page displaying all sent connections and begins withdrawing from the last page.

Cron Job

To connect with people daily, I created a Bash script that automatically starts the Python bot at random times every day.
The run_cron_job.sh script sets up a cron job that runs every day at 7 AM, scheduling the Bot to execute at a random time between 7 AM and 9:59 PM.

Installation and Setup

Please refer to the README.md file for a detailed guide and an explanation of the files.

Organizations

In the org folder, you'll find a scraping notebook for topuniversities website, which I use to scrap the top universities worldwide. The notebook can also work for top universities within a specific continent. Simply find the correct URL (e.g. https://www.topuniversities.com/europe-university-rankings), paste it into the url variable, and execute the notebook.

Proof of Concept

First, I will demonstrate the normal workflow of the bot.

Second, the captcha resolution and phone code verification. The rest is identical to the these examples.

Conclusion

The LinkedIn Bot offers a powerful way to automate and streamline your LinkedIn networking efforts. By automating connection requests and managing pending invitations, you can focus on building meaningful relationships and expanding your professional network. While automation brings efficiency, remember to use this tool responsibly and ethically, respecting LinkedIn's terms of service and focusing on genuine connections. We encourage you to explore the code, contribute improvements, and adapt the bot to your specific networking needs. Happy connecting!



P.S Contact me if you need help or more functionalities.

Credits:

Main photo: WrongTog on Unsplash