News
2
min read

How To Convert Linkedin Company To Website URL?

This guide provides a step-by-step approach to converting a LinkedIn company profile URL into a website URL using Piloterr's API.
Written by
Josselin Liebe
Published on
November 21, 2023
Readers rating
48
votes

In the realm of business and professional networking, LinkedIn plays a crucial role. Often, there's a need to extract more detailed information from a LinkedIn profile, especially for companies. This is where Piloterr's API comes into play, offering a seamless way to transform LinkedIn URLs into comprehensive website data.

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 Company URL : When you have the LinkedIn URL of the company, the process is straightforward. Use a GET request to the Piloterr API.
  • Scenario 2: Unknown LinkedIn Company 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 Company URL

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

PILOTERR_API_KEY = 'YOUR-TOKEN-API-REPLACE-ME'
LINKEDIN_URL = 'https://linkedin.com/company/airbusgroup'

def get_linkedin_info(known_url: str):
    api_url = f"https://piloterr.com/api/v2/linkedin/company/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("Website: " + req["website"])

Result

Website: http://www.airbus.com

Scenario Unknown LinkedIn Company URL

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

  1. Copy the code
  2. Create a new file get_website_linkedin_company_name.py
  3. Replace the API token with your own
  4. Replace COMPANY by the company name
  5. Run the script with py get_website_linkedin_company_name.py
import requests

PILOTERR_API_KEY = 'YOUR-TOKEN-API-REPLACE-ME'
COMPANY = 'Piloterr'

def get_linkedin_info(known_url: str):
    api_url = "https://piloterr.com/api/v2/linkedin/company/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/company/' 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/company {COMPANY}"
linkedin_url = get_linkedin_url_from_google(search_query)

if "linkedin.com/company/" in linkedin_url:
    req = get_linkedin_info(linkedin_url)
    if "website" in req:
        print("Website: " + req["website"])
    else:
        print("Error: LinkedIn information not retrieved")
else:
    print("Company not found")

Result

Website: http://www.piloterr.com

If you'd like to do the same for Linkedin profiles, take a look at our article on how to convert a first name and last name into a linkedin url.

Piloterr web scraping api
Get 1000 requests
Discover Piloterr, the all-in-one scraping API. Sign up now and get 1000 free requests per month.⚡

Take a look at our blog posts

Interviews, tips, guides, industry best practices and news.
How To Convert First Name and Last Name To Linkedin URL?
News
2
min read

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

Guide on leveraging the API to seamlessly convert first names and last names into Linkedin URL
Read post
How To Convert Linkedin Company To Website URL?
News
2
min read

How To Convert Linkedin Company To Website URL?

Guide provides a step-by-step approach to converting a LinkedIn company profile URL into a URL.
Read post
Google's boolean operators for searching Linkedin [Guide 2024]
Scraping
1
min read

Google's boolean operators for searching Linkedin [Guide 2024]

Find almost anything with these Google Booleans Searches.
Read post