Automate LinkedIn Connections using Python

In today's world, LinkedIn connections are a very important part of an IT professional life. Users have to send connection requests to many other connections that can be useful, but sometimes sending requests one by one can be a time-consuming and hectic task. Wouldn't it be better to have an automation system that can do all this work for us?

In this tutorial, we will learn how to generate an automation system for accepting the connection requests of LinkedIn using Python.

Modules required:

  • Selenium: The Selenium does not come as an inbuilt module with Python. For installing the selenium module, we can use the following command:
    !pip3 install selenium
  • Pyautogui: same as selenium, it also does not come as an inbuilt module in Python, and for installing this module, we can use the following command:
    !pip3 install pyautogui
  • Chrome web driver: we can download chrome web driver from

Before implementing it, we should import all the modules first.

Now, let's write the main function-

Now, we have to go to the authentication page, and then we have to log in.

Code:

The find_elemet_by_id is used for finding the HTML tag saying"login-email" and "login-password" then, we will send the keys to them.

Now, we will set the network section:

Code:

Now, we know that LinkedIn will try to prevent the scraping. Therefore it would be difficult for us to find the connection button. We can use a technique like Xpath.

Code:

This is how we can send the automated connection request in Linkedin using a web driver in Python.

The full implementation of code:

Output:

The number of connection requests: 12
All requests are sent!

Conclusion

In this tutorial, we discussed how we could generate an automated system for sending connection requests from LinkedIn using a web driver in Python.