Skip to main content
Piloterr
Back to blog
November 28, 2023

How To Convert First Name and Last Name To Linkedin URL?

In the realm of professional networking, LinkedIn stands as a pivotal platform for connecting individuals and businesses. Expanding on its utility, Piloterr's API emerges as a valuable tool, providing a seamless method for extracting detailed information from LinkedIn profiles, particularly for companies seeking comprehensive data. This article guides you through the process of leveraging Piloterr's API to convert first names and last names into LinkedIn URLs, offering a step-by-step approach for both known and unknown LinkedIn profile scenarios.

Automate LinkedIn lookups with the LinkedIn Profile API or explore all LinkedIn endpoints.

1. Create your account

  • Register on piloterr.com
  • Create your subscription
  • Create and copy your API key

2. Select the scenario

  • Scenario 1: Known LinkedIn Profile URL : When you have the LinkedIn URL of the profile, the process is straightforward. Use a GET request to the Piloterr API.
  • Scenario 2: Unknown LinkedIn Profile URL : In cases where you don't have the LinkedIn URL, you can still find the necessary information using a two-step process.

Remember to replace PILOTERR_API_KEY with your actual API key. The script assumes the Piloterr API responses are in a specific format, so it might require adjustments based on the actual API response structure.

Scenario Known LinkedIn Profile URL

  1. Copy the code
  2. Create a new file get_profile_linkedin.py
  3. Replace the API token with your own
  4. Replace variable LINKEDIN_URL by your URL
  5. Run the script with python get_profile_linkedin.py
Python
import requests

PILOTERR_API_KEY = 'YOUR-TOKEN-API-REPLACE-ME'
LINKEDIN_URL = 'https://www.linkedin.com/in/williamhgates'

def get_linkedin_info(known_url: str):
    api_url = f"https://piloterr.com/api/v2/linkedin/profile/info"
    headers={
        "x-api-key": PILOTERR_API_KEY
    }
    params={
        "query": known_url
    }
    response = requests.get(
        url=api_url,
        headers=headers,
        params=params
    )
    if response.status_code == 200:
        return response.json()
    else:
        return "Error: Unable to fetch data"

# Request
req = get_linkedin_info(known_url=LINKEDIN_URL)

print("Name: " + req["full_name"])

Result

Profile: Bill Gates

Scenario Unknown LinkedIn Profile URL

To enhance the script by adding a Google search request for situations where the LinkedIn Profile URL is unknown, we can introduce a new function that queries Google's Search Engine Results Page (SERP) to find the LinkedIn Profile URL.

  1. Copy the code
  2. Create a new file get_linkedin_profile_url_with_name.py
  3. Replace the API token with your own
  4. Replace the variable NAME by the first name+last name+company
  5. Run the script with python get_linkedin_profile_url_with_name.py
Python
import requests

PILOTERR_API_KEY = 'YOUR-TOKEN-API-REPLACE-ME'
NAME = 'Bill Gates Microsoft'

def get_linkedin_info(known_url: str):
    api_url = "https://piloterr.com/api/v2/linkedin/profile/info"
    headers = {
        "x-api-key": PILOTERR_API_KEY
    }
    params = {
        "query": known_url
    }
    response = requests.get(
        url=api_url,
        headers=headers,
        params=params
    )
    if response.status_code == 200:
        return response.json()
    else:
        return "Error: Unable to fetch data"

def get_linkedin_url_from_google(query: str):
    google_api_url = "https://piloterr.com/api/v2/google/search"
    headers = {
        "x-api-key": PILOTERR_API_KEY
    }
    data = {
        "query": query
    }
    response = requests.post(
        url=google_api_url,
        headers=headers,
        json=data
    )

    if response.status_code == 200:
        search_results = response.json()['organic_results']
        # Extract LinkedIn URL from search results
        for result in search_results:
            if 'linkedin.com/in/' in result['link']:
                return result['link']
        return "LinkedIn URL not found in search results"
    else:
        return "Error: Unable to perform search"

# Example usage
search_query = f"site:linkedin.com/in {NAME}"
linkedin_url = get_linkedin_url_from_google(search_query)

if "linkedin.com/in/" in linkedin_url:
    req = get_linkedin_info(linkedin_url)
    if "full_name" in req:
        print("Profile: " + req["full_name"] + " - " + req["profile_url"])
    else:
        print("Error: LinkedIn information not retrieved")
else:
    print("Profile not found")

Result

Profile: Bill Gates - https://www.linkedin.com/in/williamhgates

If you'd like to do the same for Linkedin companies, take a look at our article on how to convert a company into a linkedin url.

More to read

Guides and news about web scraping, proxies, and data extraction.

News

Understanding p50, p75, p90, p95, and p99 latency metrics

Latency percentiles explain how fast your API or scraping pipeline really performs for most requests and for the slow tail. Learn what p50 through p99 mean, why averages lie, and how to set realistic SLAs.

Josselin Liebe
Josselin Liebe
Read
News

Cloudflare teams with Chrome, Firefox, and Edge on PACT, a privacy-first anti-bot protocol

Cloudflare joins Mozilla, Google, Microsoft, and Shopify to develop PACT (Private Access Control Tokens), a standard meant to authenticate human and authorized agent traffic without CAPTCHAs or invasive tracking.

Josselin Liebe
Josselin Liebe
Read
News

Introducing the new Piloterr website

Piloterr.com has been rebuilt from the ground up: clearer product pages, 500 documented API endpoints, free developer tools, French localization, and a roadmap toward a second owned datacenter.

Josselin Liebe
Josselin Liebe
Read

Ready to get started?

Your web scraping API is one click away. Start with +500 credits, no infrastructure to set up, no proxies to manage, and no credit card required.

  • +500 credits
  • No credit card required
  • All endpoints included