How to Scrape LinkedIn Profile Data in Google Sheets: A Step-by-Step Guide

Introduction: The Importance of LinkedIn Data for Professionals

LinkedIn is the go-to platform for professionals to network, share achievements, and explore job opportunities. Businesses and individuals alike often need LinkedIn data better to understand potential clients, competitors, or partners. Gathering data from LinkedIn profiles can be tedious, especially for large datasets, making automation essential.

By scraping LinkedIn profiles into Google Sheets, you can streamline your data collection process. Whether you’re a recruiter, marketer, or sales professional, this method saves time and ensures you have structured, up-to-date information. With Google Sheets, you can automate this task by using Google Apps Script and LinkedIn’s API through RapidAPI.

Step 1: Using RapidAPI to Access LinkedIn Data

To access LinkedIn data, we’ll use the LinkedIn Data API available through RapidAPI, which simplifies data scraping by providing endpoints that fetch information from LinkedIn profiles. Here’s how you can set up access:

  1. Create a RapidAPI Account: Visit RapidAPI and create an account if you don’t have one already.
  2. Subscribe to LinkedIn API: Search for the “LinkedIn Data API” and subscribe to its free or paid plan depending on your requirements.
  3. Get API Key: After subscribing, you’ll get an API key that you’ll use to authenticate requests. Keep this key secure.

This API allows you to input the LinkedIn username and get detailed data such as name, headline, current job title, location, and profile picture URL.

Step 2: Writing a Script to Fetch LinkedIn Profile Data

Once your RapidAPI account is set up and you have your API key, the next step is to create a script in Google Sheets to fetch the LinkedIn profile data. We’ll be using Google Apps Script for this.

Below is the script to fetch LinkedIn data by entering a LinkedIn username into cell B1 of a specific sheet (e.g., “Sheet6”).

LinkedIn Profile Data in Google Sheets
Insert your LinkedIn profile Username in Cell B1, then Click on Get Profile Data, Behind this works the following script
function getLinkedInData() {
  var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Sheet6");

  // Get the LinkedIn username from cell B1
  var username = sheet.getRange("B1").getValue();

  // API request URL, using the username from the sheet
  var url = `https://linkedin-data-api.p.rapidapi.com/?username=${username}`;

  // API headers
  var options = {
    "method": "GET",
    "headers": {
      "x-rapidapi-host": "linkedin-data-api.p.rapidapi.com",
      "x-rapidapi-key": "YOUR_RAPIDAPI_KEY_HERE"  // Replace with your API key
    }
  };

  // Make the API request
  var response = UrlFetchApp.fetch(url, options);
  var data = JSON.parse(response.getContentText());

  // Insert the data as a JSON string into cell C1 for further processing
  sheet.getRange("C1").setValue(JSON.stringify(data));
}

Explanation:

  • This script fetches the LinkedIn data using the username from cell B1.
  • It sends a GET request to the LinkedIn API via RapidAPI.
  • The resulting data is stored in cell C1 of “Sheet6” in JSON format, making it available for further processing.

Step 3: Populating LinkedIn Profile Data into Google Sheets

By Running following Script your data will be sorted and pasted into linkedintable

Once we have the LinkedIn data in JSON format, we need to parse it and display it neatly in a dedicated sheet called LinkedInTable. You can use the following script to automatically populate the profile data.

function parseLinkedInData() {
  var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("LinkedInTable");

  // Fetch the JSON data from cell C1 in Sheet6
  var jsonData = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Sheet6").getRange("C1").getValue();

  // Parse the JSON data
  var data = JSON.parse(jsonData);

  // Define the headers for the columns (only needed for the first row)
  var headers = [
    "ID", 
    "LinkedIn URL", 
    "First Name", 
    "Last Name", 
    "Current Title", 
    "Profile Picture URL", 
    "Background Image URL", 
    "Summary", 
    "Headline", 
    "Location"
  ];

  // Check if headers exist, if not, set the headers in the first row
  if (sheet.getLastRow() === 0) {
    sheet.getRange(1, 1, 1, headers.length).setValues([headers]);
  }

  // Extract and organize the values to be inserted into the sheet
  var values = [
    data.id,
    `https://www.linkedin.com/in/${data.username}`,  // Construct LinkedIn URL from username
    data.firstName,
    data.lastName,
    data.position[0].title,  // Current title (first position in the list)
    data.profilePicture,  // Profile picture URL
    data.backgroundImage[0].url,  // Background image URL
    data.summary,
    data.headline,
    data.geo.full  // Location
  ];

  // Determine the next available row after existing data
  var nextRow = sheet.getLastRow() + 1;

  // Insert the values into the sheet starting at the next available row
  sheet.getRange(nextRow, 1, 1, values.length).setValues([values]);
}

Explanation:

  • This script fetches the JSON data stored in cell C1 of “Sheet6.”
  • It then parses the data, extracts useful information such as ID, first name, last name, current title, profile picture, and location.
  • The data is displayed in the LinkedInTable sheet, starting from the second row. If more profiles are scraped, the new data is automatically appended to the next available row.

Step 4: Overview of Data Extracted from LinkedIn

With this setup, you can extract the following LinkedIn data points and display them in your Google Sheets:

  1. ID: The unique LinkedIn ID.
  2. LinkedIn URL: A clickable link to the profile.
  3. First Name and Last Name: The individual’s personal details.
  4. Current Title: The title or role they currently hold.
  5. Profile Picture URL: A link to their profile image.
  6. Background Image URL: A link to the background image on their profile.
  7. Summary: Their LinkedIn summary, which often gives an overview of their professional experience.
  8. Headline: Their headline, which is typically a quick statement of their role or mission.
  9. Location: The city or region they are based in.

Closing Remarks: Automating LinkedIn Scraping for Professional Use

By combining the power of RapidAPI and Google Apps Script, you can automate LinkedIn data scraping directly into Google Sheets. This method allows you to gather valuable professional data effortlessly, ensuring you’re always up to date with the latest information. Whether you’re tracking competitor profiles, gathering insights on prospective hires, or analyzing professional networks, this solution is scalable and customizable to suit your needs.

This approach streamlines your workflow, letting you focus on analyzing the data rather than collecting it. Always ensure you follow LinkedIn’s terms of service and guidelines to avoid any compliance issues when using such automated solutions.

If you have concerns Please message me at info@datatipss.com, Want to hire me upwork?? Here is link

9 thoughts on “How to Scrape LinkedIn Profile Data in Google Sheets: A Step-by-Step Guide”

  1. Идеи для изготовления креативных квадратных номеров, Лучшие способы оформить номер в форме квадрата

Leave a Comment

Your email address will not be published. Required fields are marked *