Ejemplo n.º 1
0
def extractProfile(jelement, company_name, company_id):
    '''Derive and return Peasant.profile object from an element.
    '''

    j = jelement
    '''Path to profile information from element:
    - /hitInfo/com.linkedin.voyager.search.SearchProfile
    '''

    profile = j['hitInfo']['com.linkedin.voyager.search.SearchProfile']

    # get industry/location information
    industry = profile.get('industry')
    location = profile.get('location')

    # get profile information

    mini_profile = profile['miniProfile']
    first_name = mini_profile['firstName']
    last_name = mini_profile['lastName']
    occupation = mini_profile['occupation']
    public_identifier = mini_profile['publicIdentifier']
    entity_urn = mini_profile['entityUrn']
    if entity_urn:
        try:
            entity_urn = entity_urn.split(':')[-1]
        except:
            entity_urn = None

    # return a Peasant.profile object
    return Profile(first_name, last_name, occupation, public_identifier,
                   industry, location, entity_urn, company_name, company_id)
Ejemplo n.º 2
0
def extractInvitation(obj):
    '''Derive and return a Peasant.profile object from a JSON object
    ("toMember).
    '''

    return Profile(first_name=obj['firstName'],
                   last_name=obj['lastName'],
                   occupation=obj['occupation'],
                   entity_urn=obj['entityUrn'].split(':')[-1],
                   public_identifier=obj['publicIdentifier'])
Ejemplo n.º 3
0
def extractProfile(jelement, company_name, company_id):
    '''Derive and return Peasant.profile object from an element.
    '''

    j = jelement

    # Catch any exceptions related to parsuing of the JSON object
    try:

        profile = j['hitInfo'] \
                ['com.linkedin.voyager.search.SearchProfile']

        # get industry/location information
        industry = profile.get('industry')
        location = profile.get('location')

        # get profile information

        mini_profile = profile['miniProfile']
        first_name = mini_profile['firstName']
        last_name = mini_profile['lastName']
        occupation = mini_profile['occupation']
        public_identifier = mini_profile['publicIdentifier']
        entity_urn = mini_profile['entityUrn']

    except Exception as e:

        esprint('Failed to parse profile from JSON!', suf='[!]')
        raise e

    if entity_urn:
        try:
            entity_urn = entity_urn.split(':')[-1]
        except:
            entity_urn = None

    # return a Peasant.profile object
    return Profile(first_name, last_name, occupation, public_identifier,
                   industry, location, entity_urn, company_name, company_id)