Optimizing LinkedIn Profile URL Storage

  • Author
    by Josselin Liebe
    4 months ago
  • To create a list of similar LinkedIn profiles using the Piloterr API, here is a Python script example:

    1. Create a base list with LinkedIn profiles.

    2. Make a request to the Piloterr API to retrieve profile information.

    3. 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

    1. Importing the requests library: Required to make HTTP requests.

    2. Replace your_api_key with your Piloterr API key.

    3. Populate with the LinkedIn profile URLs you want to analyze.

    4. Function get_profile_info: Sends a request to the Piloterr API to retrieve profile information.

    5. Function display_similar_profiles: Iterates through each profile in the list, retrieves similar profiles, and displays them.

    Usage

    1. Replace your_api_key with your actual API key.

    2. Add LinkedIn profile URLs to the profiles list.

    3. 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.