Automate LinkedIn with Datakund

Introduction

bot-studio is an automation library which can be used to automate tasks like sending mails,scraping data,auto checkout and many more. You can download the source code from here(see here)

It uses selenium to automate the things. You can use its inbuilt functions like linkedin_follow, linkedin_login etc. in a very easy way.

Installation/Usage:

You can find this package on Pypi (see here).

Command to install :- pip install bot-studio

Import bot-studio

from bot_studio import *

Creating Object

linkedin=bot_studio.linkedin()
or
linkedin=bot_studio.linkedin(headless=True,....)

It will return the object which you can further use to call linkedin functions and opens a automated browser

Browser Options

Option

Default Value

Description

headless

False

Can set it to True if wants headless

proxy

No proxy

Pass proxy value e.g 98.0.2.5:4000

profile_path

creates temporary profile

Pass profile path e.g C:\Users\username\AppData\Local\Google\Chrome\User Data\

user_agent

No user agent

Pass user agent e.g python 2.7”, “platform”:”Windows

download_folder

Downloads in default folder

If want to set download directory to custom e.g E:files\

Functions

bot-studio provides following functions for linkedin:-

Login

It will login to linkedin via your credentials.

body: returns data

success_score: api success rate

errors: errors encountered in api

Here is the code:-

linkedin.login(username='datakund@gmail.com', password='password@123')
Parameters
  • username (str) – Linkedin username

  • password (str) – Linkedin password

Returns

{“body”: {}, “success_score”: “100”, “errors”: []}

Return type

dict

Get Job Profile

It opens the job link passed in job_link and fetches info about job.

body: returns data

success_score: api success rate

errors: errors encountered in api

Here is the code:-

linkedin.get_job_profile(job_link='https://www.linkedin.com/jobs/search?keywords=python&origin=BLENDED_SEARCH_RESULT_CARD_NAVIGATION&currentJobId=2369119694&lipi=urn%3Ali%3Apage%3Ad_flagship3_search_srp_all%3B0Rk7LgXJQnKGvr4mUZFYVg%3D%3D')
Parameters

job_link (str) – Link of the job posted

Returns

{“body”: {‘Location’: ‘Location’, ‘Employment Type’: ‘Employment Type’, ‘Company Name’: ‘Company Name’, ‘Industry’: ‘Industry’, ‘Experience’: ‘Experience’, ‘Roles’: ‘Roles’, ‘Job Functions’: ‘Job Functions’, ‘Applicants’: ‘Applicants’, ‘Title’: ‘Title’, ‘Published’: ‘Published’, ‘Seniority Level’: ‘Seniority Level’}, “success_score”: “100”, “errors”: []}

Return type

dict

Search People

It searches the keyword passed in keyword and opens people.

body: returns data

success_score: api success rate

errors: errors encountered in api

Here is the code:-

linkedin.search_people(keyword='Hr manager')
Parameters

keyword (str) – Keyword need to be searched like hr,python

Returns

{“body”: {}, “success_score”: “100”, “errors”: []}

Return type

dict

Search Jobs

It searches the keyword passed in keyword and opens jobs.

Here is the code:-

linkedin.search_jobs(keyword='Python Developer')
Parameters

keyword (str) – Keyword need to be searched like hr,python

Returns

{}

Return type

dict

Search Posts

It searches the keyword passed in keyword and opens content.

body: returns data

success_score: api success rate

errors: errors encountered in api

Here is the code:-

linkedin.search_posts(keyword='Data Science')
Parameters

keyword (str) – Keyword need to be searched like hr,python

Returns

{“body”: {}, “success_score”: “100”, “errors”: []}

Return type

dict

Enter Job Location

It fills location passed in location on search results page.

body: returns data

success_score: api success rate

errors: errors encountered in api

Here is the code:-

linkedin.enter_job_location(location='Delhi')
Parameters

location (str) – pass location like delhi,goa

Returns

{“body”: {}, “success_score”: “100”, “errors”: []}

Return type

dict

Send Message

It sends message to user passed in profile_link with message as message.

body: returns data

success_score: api success rate

errors: errors encountered in api

Here is the code:-

linkedin.send_message(message='Hi', profile_link='https://www.linkedin.com/in/abhishek-chaudhary-/')
Parameters
  • message (str) – message which need to be send

  • profile_link (str) – profile link of user whom message need to be sent

Returns

{“body”: {}, “success_score”: “100”, “errors”: []}

Return type

dict

Follow Company

It follows the company passed in company_link.

body: returns data

success_score: api success rate

errors: errors encountered in api

Here is the code:-

linkedin.follow_company(company_link='https://www.linkedin.com/company/microsoft/')
Parameters

company_link (str) – company link which need to be followed

Returns

{“body”: {}, “success_score”: “100”, “errors”: []}

Return type

dict

Unfollow Company

It unfollows the company passed in company_link.

body: returns data

success_score: api success rate

errors: errors encountered in api

Here is the code:-

linkedin.unfollow_company(company_link='https://www.linkedin.com/company/microsoft/')
Parameters

company_link (str) – company link which need to be unfollowed

Returns

{“body”: {}, “success_score”: “100”, “errors”: []}

Return type

dict

Send Connection

It sends conection request to the user passed in profile_link.

body: returns data

success_score: api success rate

errors: errors encountered in api

Here is the code:-

linkedin.send_connection(profile_link='https://www.linkedin.com/in/abhishek-chaudhary-/')
Parameters

profile_link (str) – Profile link of user to whom connection need to be sent

Returns

{“body”: {}, “success_score”: “100”, “errors”: []}

Return type

dict

Get Profile

It fetches the profile of the user passed in profile_link.

body: returns data

success_score: api success rate

errors: errors encountered in api

Here is the code:-

linkedin.get_profile(profile_link='https://www.linkedin.com/in/abhishek-chaudhary-/')
Parameters

profile_link (str) – Profile link of user whose data need to be fetched

Returns

{“body”: {‘Location’: ‘Location’, ‘Info’: ‘Info’, ‘Education’: ‘Education’, ‘About’: ‘About’, ‘Experience’: ‘Experience’, ‘Education_Info’: ‘Education_Info’, ‘Recommendations’: ‘Recommendations’, ‘Mutual_Connections’: ‘Mutual_Connections’, ‘Name’: ‘Name’, ‘Interests’: ‘Interests’, ‘Current Company’: ‘Current Company’}, “success_score”: “100”, “errors”: []}

Return type

dict

Get Company Profile

It fetches the profile of the company passed in company_link.

body: returns data

success_score: api success rate

errors: errors encountered in api

Here is the code:-

linkedin.get_company_profile(company_link='https://www.linkedin.com/company/microsoft/')
Parameters

company_link (str) – Company link whose data need to be fetched

Returns

{“body”: {‘Location’: ‘Location’, ‘Company Name’: ‘Company Name’, ‘Industry’: ‘Industry’, ‘Info’: ‘Info’, ‘Followers’: ‘Followers’, ‘Overview’: ‘Overview’, ‘Type’: ‘Type’, ‘Founded’: ‘Founded’, ‘Website’: ‘Website’, ‘Company Size’: ‘Company Size’, ‘Specialities’: ‘Specialities’}, “success_score”: “100”, “errors”: []}

Return type

dict

Click Next

It clicks on Next button on search results page.

Here is the code:-

linkedin.click_next()
Returns

{}

Return type

dict

People Results

It fetches the data of people on people search results page.

body: returns data

success_score: api success rate

errors: errors encountered in api

Here is the code:-

linkedin.people_results()
Returns

{“body”: [{‘Link’: ‘Link’}], “success_score”: “100”, “errors”: []}

Return type

dict

Jobs Results

It fetches the data of jobs on job search results page.

body: returns data

success_score: api success rate

errors: errors encountered in api

Here is the code:-

linkedin.jobs_results()
Returns

{“body”: [{‘Link’: ‘Link’}], “success_score”: “100”, “errors”: []}

Return type

dict

Posts Results

It fetches the data of posts on content search results page.

body: returns data

success_score: api success rate

errors: errors encountered in api

Here is the code:-

linkedin.posts_results()
Returns

{“body”: [{‘User Link’: ‘User Link’, ‘Post Text’: ‘Post Text’}], “success_score”: “100”, “errors”: []}

Return type

dict

Open Connections

It opens connections of the user passed in profile_link.

body: returns data

success_score: api success rate

errors: errors encountered in api

Here is the code:-

linkedin.open_connections(profile_link='https://www.linkedin.com/in/bhawna-vashisht-444174117/')
Parameters

profile_link (str) – Profile link whose connections need to be opened

Returns

{“body”: {}, “success_score”: “100”, “errors”: []}

Return type

dict

Comment On Post

It comments on the post passed in post_link with comment in comment.

body: returns data

success_score: api success rate

errors: errors encountered in api

Here is the code:-

linkedin.comment_on_post(post_link='https://www.linkedin.com/posts/er-chirag-grover-290918101_help-androiddevelopment-flutterappdevelopment-activity-6766960247794937856-2jh3', comment='Please share your resume here abc@gmail.com')
Parameters
  • post_link (str) – post link where need to comment

  • comment (str) – Text need to comment on post

Returns

{“body”: {}, “success_score”: “100”, “errors”: []}

Return type

dict

Get Messages

It fetch messages of user passed in profile_link.

body: returns data

success_score: api success rate

errors: errors encountered in api

Here is the code:-

linkedin.get_messages(profile_link='https://www.linkedin.com/in/abhishek-chaudhary-/')
Parameters

profile_link (str) – Profile link whose messages need to be fetched

Returns

{“body”: {‘Messegetext’: ‘Messegetext’}, “success_score”: “100”, “errors”: []}

Return type

dict

Send Message By Name

It searches the keyword passed in keyword and clicks on first search result and send message passed in message.

body: returns data

success_score: api success rate

errors: errors encountered in api

Here is the code:-

linkedin.send_message_by_name(message='Hi', keyword='DataKund')
Parameters
  • message (str) – Text need to comment on post

  • keyword (str) – Name of the user who need to be searched

Returns

{“body”: {}, “success_score”: “100”, “errors”: []}

Return type

dict

Upload Content

It uploads the post passed in content.

body: returns data

success_score: api success rate

errors: errors encountered in api

Here is the code:-

linkedin.upload_content(content='Hi, hope all are doing well.....')
Parameters

content (str) – Post text need to be posted on linkedin

Returns

{“body”: {}, “success_score”: “100”, “errors”: []}

Return type

dict

Search Companies

It searches the keyword passed in keyword and opens companies results.

body: returns data

success_score: api success rate

errors: errors encountered in api

Here is the code:-

linkedin.search_companies(keyword='machine learning')
Parameters

keyword (str) – Search keyword like microsoft,google

Returns

{“body”: {}, “success_score”: “100”, “errors”: []}

Return type

dict

Get Feed

It fetches the post content on linkedin feed page.

body: returns data

success_score: api success rate

errors: errors encountered in api

Here is the code:-

linkedin.get_feed()
Returns

{“body”: [{‘Post Content’: ‘Post Content’, ‘UserLink’: ‘UserLink’, ‘User Name’: ‘User Name’}], “success_score”: “100”, “errors”: []}

Return type

dict

Companies Results

It fetches the companies data on search results page.

body: returns data

success_score: api success rate

errors: errors encountered in api

Here is the code:-

linkedin.companies_results()
Returns

{“body”: [{‘CompanyLink’: ‘CompanyLink’, ‘Followers’: ‘Followers’, ‘Type’: ‘Type’, ‘Title’: ‘Title’}], “success_score”: “100”, “errors”: []}

Return type

dict

Search Groups

It searches the keyword passed in keyword and opens group results.

body: returns data

success_score: api success rate

errors: errors encountered in api

Here is the code:-

linkedin.search_groups(keyword='artificial intelligence')
Parameters

keyword (str) – Search keyword like python,machine learning

Returns

{“body”: {}, “success_score”: “100”, “errors”: []}

Return type

dict

Groups Results

It fetches data on group search results page.

body: returns data

success_score: api success rate

errors: errors encountered in api

Here is the code:-

linkedin.groups_results()
Returns

{“body”: [{‘Group Link’: ‘Group Link’, ‘Title’: ‘Title’, ‘Members’: ‘Members’}], “success_score”: “100”, “errors”: []}

Return type

dict

Join Group

It joins the group passed in group_link.

body: returns data

success_score: api success rate

errors: errors encountered in api

Here is the code:-

linkedin.join_group(group_link='https://www.linkedin.com/groups/2066905?lipi=urn%3Ali%3Apage%3Ad_flagship3_search_srp_groups%3BJVAIN209Q7S4FagNFJvIug%3D%3D')
Parameters

group_link (str) – Link of group which need to be joined

Returns

{“body”: {}, “success_score”: “100”, “errors”: []}

Return type

dict

Get Post

It fetches data of post passed in post_link.

body: returns data

success_score: api success rate

errors: errors encountered in api

Here is the code:-

linkedin.get_post(post_link='https://www.linkedin.com/feed/update/urn:li:activity:6764456234197295104?updateEntityUrn=urn%3Ali%3Afs_feedUpdate%3A%28V2%2Curn%3Ali%3Aactivity%3A6764456234197295104%29')
Parameters

post_link (str) – Link of post whose data need to be fetched

Returns

{“body”: {‘Time’: ‘Time’, ‘Post Text’: ‘Post Text’, ‘Profile_Link’: ‘Profile_Link’, ‘Likes’: ‘Likes’, ‘UserName’: ‘UserName’, ‘Bio’: ‘Bio’, ‘Comments’: ‘Comments’}, “success_score”: “100”, “errors”: []}

Return type

dict

Get Comments

It fetches the comments of the post currently opened in browser.

body: returns data

success_score: api success rate

errors: errors encountered in api

Here is the code:-

linkedin.get_comments()
Returns

{“body”: [{‘User Link’: ‘User Link’, ‘Comment’: ‘Comment’, ‘UserName’: ‘UserName’, ‘Info’: ‘Info’}], “success_score”: “100”, “errors”: []}

Return type

dict

Click Load More

It clicks on click more on the comments page currently opened in browser.

body: returns data

success_score: api success rate

errors: errors encountered in api

Here is the code:-

linkedin.click_load_more()
Returns

{“body”: {}, “success_score”: “100”, “errors”: []}

Return type

dict

Accept Invitation

It accepts first invitation on invitation page

body: returns data

success_score: api success rate

errors: errors encountered in api

Here is the code:-

linkedin.accept_invitation()
Returns

{“body”: {}, “success_score”: “100”, “errors”: []}

Return type

dict

Clicknext

It clicks on Next button on search results page.

body: returns data

success_score: api success rate

errors: errors encountered in api

Here is the code:-

linkedin.clicknext()
Returns

{“body”: {}, “success_score”: “100”, “errors”: []}

Return type

dict

Other Functions

You can use basic functions which selenium provides with this library like opening a url, get pagesource, get current url etc. These are the functions:-

Open

It will open the url provided in the argument.

linkedin.open(url)
Parameters

url (str) – Link which need to be opened

Returns

{}

Return type

dict

Get Page Title

It returns the title of page opened.

linkedin.get_page_title()
Returns

{“pagetitle”:”Linkedin”}

Return type

dict

Get Page Source

It returns the pagesource of page opened.

linkedin.get_page_source()
Returns

{“pagesource”:”pagesource”}

Return type

dict

Get Current Url

It returns the pagesource of page opened.

linkedin.get_current_url()
Returns

{“url”:”url”}

Return type

dict

Reload

It reloads the page opened.

linkedin.reload()
Returns

{}

Return type

dict

Keypress

It perform the keypress passed.

linkedin.keypress(key)
Parameters

key (str) – Key which need to be pressed, e.g pagedown,arrowleft,enter

Returns

{}

Return type

dict

Scroll

It scrolls to the end of page.

linkedin.scroll()
Returns

{}

Return type

dict

End

It ends the linkedin session and close the automated chromedriver.

Note

You will need to create linkedin object again after end().

linkedin.end()
Returns

{}

Return type

dict

Quit

It quits the bot-studio application runing in background.

Note

You will need to import bot-studio library again to start application.

linkedin.quit()
Returns

{}

Return type

dict