Skip to main content
Piloterr
Back to blog
October 3, 2024

How to Find the URL of a Relevant Linkedin Profile [Python Code]

Why do you need to find LinkedIn profile URLs?

Skip the boilerplate: use the LinkedIn Profile API with managed anti-bot bypass.

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
Python
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)

More to read

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

Scraping

Web scraping for automotive: tracking car prices and parts across AutoScout24, Mobile.de, Leboncoin, and Autodoc

How automotive pricing platforms use scraping APIs to monitor used-car listings on AutoScout24, Mobile.de, and Leboncoin, and parts prices across Autodoc's 30+ national shops. Pipeline design, API examples, and a Python script.

Josselin Liebe
Josselin Liebe
Read
Scraping

Web scraping for brand protection: hunting counterfeits on AliExpress, Alibaba, and Amazon

How brand protection platforms use scraping APIs to detect counterfeit listings, capture seller evidence, and monitor re-listings across AliExpress, Alibaba, Amazon, and other marketplaces. Pipeline design, API examples, and a Python script.

Josselin Liebe
Josselin Liebe
Read
Scraping

Migrating from NetNut: what to do after the network takedown

Google took action against the NetNut/Popa proxy network alongside the FBI and Lumen. How to rethink your scraping stack without managing proxies yourself.

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