Extract data from a LinkedIn profile
Overview
This recipe demonstrates how to extract data from a LinkedIn profile. It uses Airtop’s Live View, Profiles, and Page Query APIs to allow a user to log in to LinkedIn and extract data from their profile. Once logged in, an agent can re-use the user’s profile to log in and extract additional data from other LinkedIn profiles autonomously.
Demo
A live demo of this recipe is available here. You can sign up to create an API key for free and try it out yourself!
Running Locally
To get started, ensure you have:
- Node.js installed on your system.
- An Airtop API key. You can get one for free.
- Clone the repository and install dependencies
- Run the CLI. This will run the agent on the command line and is useful for quickly testing the agent.
- (optional) Run the web application. This will start the Next.js app that is demoed in the video above.
Walkthrough
Although this recipe seems to have a lot of code for the CLI and for the web app, the core logic is actually quite simple and entirely encapsulated in the linkedin-extractor.service.ts
file. The LinkedInExtractorService
class encapsulates all the agent specific logic and has methods for initializing a session, checking if the user is signed in, extracting data from the user’s profile, and terminating the session.
Creating a new session and window
The following code creates a new session and browser window, and generates a LiveView URL for the user to sign in to LinkedIn.
Checking if a user is signed in
Checking if a user is signed in is simple and only requires a call to the Page Query API.
All the prompts and schemas are defined in the consts.ts
file.
Extracting data from a LinkedIn profile
Finally, extracting data from a LinkedIn profile is also done through a call to the Page Query API. At the end of the flow, we close the window and terminate the session.