Optimizing LinkedIn Profile URL Storage
By Josselin Liebe
To create a list of similar LinkedIn profiles using the Piloterr API, here is a Python script example:
Create a base list with LinkedIn profiles.
Make a request to the Piloterr API to retrieve profile information.
Extract and display the profiles in the people_also_viewed section.
Example Python Script
Make sure you have the requests library installed using pip install requests.
import requests
API_KEY = 'your_api_key'
profiles = [
'https://www.linkedin.com/in/xx',
'https://www.linkedin.com/in/xx',
'https://www.linkedin.com/in/xx',
]
unique_similar_profile_urls = set()
def get_profile_info(profile_url):
endpoint = 'https://piloterr.com/api/v2/linkedin/profile/info'
headers = {
'x-api-key': API_KEY
}
params = {
'query': profile_url
}
response = requests.get(endpoint, headers=headers, params=params)
if response.status_code == 200:
return response.json()
else:
return None
def collect_unique_similar_profile_urls(profiles):
for profile_url in profiles:
profile_info = get_profile_info(profile_url)
if profile_info:
similar_profiles = profile_info.get('people_also_viewed', [])
for similar_profile in similar_profiles:
url = similar_profile.get('url')
if url not in unique_similar_profile_urls:
unique_similar_profile_urls.add(url)
collect_unique_similar_profile_urls(profiles)
for url in unique_similar_profile_urls:
print(url)Explanation
Importing the
requestslibrary: Required to make HTTP requests.Replace
your_api_keywith your Piloterr API key.Populate with the LinkedIn profile URLs you want to analyze.
Function
get_profile_info: Sends a request to the Piloterr API to retrieve profile information.Function
display_similar_profiles: Iterates through each profile in the list, retrieves similar profiles, and displays them.
Usage
Replace
your_api_keywith your actual API key.Add LinkedIn profile URLs to the
profileslist.Run the script to see similar profiles for each profile in the base list.
This script provides a foundation that you can adapt according to your specific needs, such as storing the results in a file or database for later use.
Was this helpful?