How to Find the URL of a Relevant Linkedin Profile

How to Find the URL of a Relevant Linkedin Profile
Scraping

Why do you need to find LinkedIn profile URLs?

LinkedIn has become an essential platform for professional networking, as it now serves a number of purposes.

Streamline recruitment processes

For recruiters, finding LinkedIn URLs is essential to streamlining the recruitment process. LinkedIn profiles provide a comprehensive overview of a candidate's professional experience, skills and credentials.

Boost sales and lead generation

By accessing LinkedIn profiles, sales professionals can gather valuable information about prospects, such as their current roles, past experiences and mutual relationships. This information can be used to tailor presentations and build relationships. It also facilitates direct contact, enabling sales teams to generate leads and close deals more effectively. In short, LinkedIn URLs are an essential tool for boosting sales performance and driving business growth.

How do I retrieve LinkedIn profile URLs?

It couldn't be easier, I'm going to take you through it step by step. Let's take the following example, my goal is to get in touch with all the web designers in San Francisco.

Create your account

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

Case study

For our case study, let's take the example given above. This section will be divided into several themes:

  • Basic code: Very simple code that you can reproduce by copying and pasting our example.
  • Result obtained: Presentation of the result obtained by executing the code.
  • Code explanation: A general explanation of how the code works.
  • Possible improvements: Suggestions for improvements you can make yourself.

With this structure, you can easily follow the process, understand how the code works and adapt it to your needs.

Python basic code

Don't forget to replace PILOTERR_API_KEY with your real API key. The script assumes that the Piloterr API responses are in a format specific to our API, so it may need to be adjusted depending on the provider you choose.

  • Copy the code
  • Create a new file get_linkedin_profile_url.py‍
  • Replace the API token with your own
  • Replace variable JOB_TITLE & LOCATION by your need
  • Run the script with python get_linkedin_profile_url.py
import requests

PILOTERR_API_KEY = 'YOUR-API-KEY-HERE'
JOB_TITLE = 'web designer'
LOCATION = 'san francisco' 

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,
        "page": 1,
        "gl": "us",
        "hl": "us",
        "google_domains": "google.com"
    }
    response = requests.post(
        url=google_api_url,
        headers=headers,
        json=data
    )
    
    if response.status_code == 200:
        return response.json()
    else:
        print(f"Error: Unable to perform search. Status code: {response.status_code}")
        return None

def extract_links(data):
    links = []
    for result in data.get("organic_results", []):
        link = result.get("link")
        if link and 'linkedin.com/in/' in link:
            links.append(link)
    return links

# Main function that connects the two others
def search_and_extract_linkedin(query: str):
    results = get_linkedin_url_from_google(query)
    if results:
        linkedin_links = extract_links(results)
        return linkedin_links
    else:
        return []

# Usage
query = f"site:linkedin.com/in intitle:'{JOB_TITLE}' intext:'{LOCATION}'"
links = search_and_extract_linkedin(query)
‍

Results

After execution we obtain a list of linkedin urls such as :

['https://www.linkedin.com/in/michael-smith-529b5161', 
'https://www.linkedin.com/in/stevescheinberg', 
'https://www.linkedin.com/in/liufysophia', 
'https://www.linkedin.com/in/web-designer-and-developer', 
'https://www.linkedin.com/in/caramiadesign', 
'https://www.linkedin.com/in/sbdari-sf', 
'https://www.linkedin.com/in/maria-tassone', 
'https://www.linkedin.com/in/marilyn-monroy', 
'https://www.linkedin.com/in/nicolassaad', 
'https://www.linkedin.com/in/taliavo']

Code explanation

There are two techniques used in the code:

  • Google dorking: combinations of keywords recognised by the Google search engine (advanced search operators). These combinations are used to refine the search criteria, for more information on the subject click here
  • Our google search api: this api allows you to make queries directly on the search engine while using our infrastructures. For more information, here is the documentation

To understand the code in more detail:

Define constants:

  • PILOTERR_API_KEY: API key to access the Piloterr API.
  • JOB_TITLE: Job title being searched for (here, "web designer").
  • LOCATION: Location for the search (here, "San Francisco").

Function get_linkedin_url_from_google(query):

  • Builds and sends a POST request to the Piloterr API to perform a Google search.
  • Uses the API key and search parameters.
  • Returns the search results as JSON if the request is successful, otherwise returns None.

Function extract_links(data):

  • Extracts LinkedIn links from the search results.
  • Iterates through the organic results and filters those containing "linkedin.com/in/" in the link.
  • Returns a list of these links.

Possible improvements

  • Use our linkedin profile API to enrich profile information, here the documentation
  • Instead of storing data in a Python list, store it in a Google Sheet.
  • Paginate several google pages with the google search api
  • Search for several cities using a list
  • Search for job synonyms