def processLinkedInData(jobsite, searchstring, citytosearch, ziptosearch, lastDownloadedTime): authentication = linkedin.LinkedInDeveloperAuthentication('75ph7mwmqazlp9', 'wauOWNOXgZqBKBWo', '4468dda6-1a33-4007-a175-0e03dc72282b', 'a9aee8ab-984b-4a3d-b8e9-a4e459c7d10f', 'http:\\jeevansgadgets.com\getjoblist', linkedin.PERMISSIONS.enums.values()) application = linkedin.LinkedInApplication(authentication) filename = '%sjoblist.txt' % jobsite joblistfile = open(filename, 'w') totalcount = 0 loopcount = 20 while loopcount == 20: print 'downloading %s-%s' % (totalcount, totalcount+20) loopcount = 0 data = application.search_job(selectors=[{'jobs': ['id', 'customer-job-code', 'posting-date', 'active', 'company', 'position', 'site-job-url', 'location-description']}], params={'active': 'true', 'facet': 'job-function,it', 'keywords': searchstring, 'count': 20, 'start': totalcount, 'postal-code': ziptosearch, 'country-code': 'US', 'distance': 50, 'sort': 'DD'}) #print data if data["jobs"]["_total"] == 0: continue for job in data["jobs"]["values"]: loopcount = loopcount + 1 totalcount = totalcount + 1 date = datetime.datetime.strptime(str(job["postingDate"]["month"]) + '-' + str(job["postingDate"]["day"]) + '-' + str(job["postingDate"]["year"]), '%m-%d-%Y') url = job["siteJobUrl"].strip() url = re.sub('&trk.*', '', url) if date >= lastDownloadedTime: joblistfile.write(job["position"]["title"].encode('ascii', 'ignore').strip() + '\t' + url + '\t' + job["company"]["name"].encode('ascii', 'ignore').strip() + '\t' + '' + '\t' + job["locationDescription"].strip() + '\t' + date.strftime('%Y-%m-%d') + '\n')
def authenticate(): credentials = get_credentials() authentication = linkedin.LinkedInDeveloperAuthentication( credentials['consumer-key'], credentials['consumer-secret'], credentials['user-token'], credentials['user-secret'], credentials['return-url'], linkedin.PERMISSIONS.enums.values()) return linkedin.LinkedInApplication(authentication)
def linkedin_view(request): authentication = linkedin.LinkedInDeveloperAuthentication( consumer_key=settings.LINKEDIN_CONSUMER_KEY, consumer_secret=settings.LINKEDIN_CONSUMER_SECRET, user_token=settings.LINKEDIN_USER_TOKEN, user_secret=settings.LINKEDIN_USER_SECRET, redirect_uri=settings.SITE_ROOT_URI, permissions=linkedin.PERMISSIONS.enums.values()) application = linkedin.LinkedInApplication(authentication) profile_data = application.get_profile(selectors=[ 'id', 'first-name', 'last-name', 'headline', 'location', 'num-connections', 'skills', 'educations', 'picture-url', 'site-standard-profile-request', 'summary', 'positions', 'industry' ]) group_data = application.get_memberships() network_updates_data = application.get_network_updates( types=LINKEDIN_NETWORK_UPDATE_TYPES) context = { 'profile': profile_data, 'groups': group_data, 'network_updates': network_updates_data } return HttpResponse(content=json.dumps(context), status=200, content_type='application/json')
def __init__(self, token_set, who): self.who = who ################################# # Linked In keys # ################################# CONSUMER_KEY = token_set['CONSUMER_KEY'] CONSUMER_SECRET = token_set['CONSUMER_SECRET'] USER_TOKEN = token_set['USER_TOKEN'] USER_SECRET = token_set['USER_SECRET'] print "Connecting to linkedIn." auth = linkedin.LinkedInDeveloperAuthentication( CONSUMER_KEY, CONSUMER_SECRET, USER_TOKEN, USER_SECRET, 'http://localhost', permissions=linkedin.PERMISSIONS.enums.values()) print "Authenticating." self.lnk = linkedin.LinkedInApplication(auth) print "Getting %s's connections." % self.who self.load_linkedin_connections() print "Processing list." # load clean up mappings self.cleanup_company = {} self.cleanup_email = {} f = open("cleanup_company.txt") for line in f.readlines(): x = line.split(":") self.cleanup_company[x[0]] = x[1] self.cleanup_email[x[0]] = x[2].strip() f.close()
def test(self): """ Main test method for testing the extractors. """ # Constants needed to test the extractor. # NOTE: The test is using a fake LinkedIn profile we created. # This means we know what names/skills should be returned and how many. # API keys CONSUMER_KEY = '77d39rnu0jgxhc' CONSUMER_SECRET = 'SRjbrl5ajSwkbpMH' USER_TOKEN = 'c87cfe99-0997-4393-bc8a-09bc60bbbaf4' USER_SECRET = '1e37a040-934a-4047-8852-4fdc5c378b7c' RETURN_URL = 'http://www.google.com' # Skills we have entered for the profile. NEEDEDSKILLS = [ "PHP", "Python", "Management", "Scrum", "People Skills", "Synergies", "Love Of Learning", "Bearings", "Pipe", "COBOL", "Brain Tumors", "Testing", "Debugging", "Entertainment", "Enterprise Software" ] # Authenticate and create an application. authentication = linkedin.LinkedInDeveloperAuthentication( CONSUMER_KEY, CONSUMER_SECRET, USER_TOKEN, USER_SECRET, RETURN_URL, linkedin.PERMISSIONS.enums.values()) application = linkedin.LinkedInApplication(authentication) # Extract the following fields from the profile. fields = "first-name,last-name,skills" data = application.get_profile(None, None, fields) # Get the fields we need from the JSON. firstname = data['firstName'] lastname = data['lastName'] skills = data['skills'] totalSkills = skills['_total'] skillList = skills['values'] # Check of the names are correct and that # the correct number of skills was returned. self.assertEqual(firstname, "test") self.assertEqual(lastname, "profile") self.assertEqual(totalSkills, 15) # Loop through the skills and check that they are what we expect. for skill in skillList: skillstr = skill['skill']['name'] if not (skillstr in NEEDEDSKILLS): self.fail("Unexpected skill:" + skillstr) else: NEEDEDSKILLS.remove(skillstr) # Check that we did recieve all the expected skills. self.assertEqual(len(NEEDEDSKILLS), 0)
def get_results(job_title, zip_code): API_KEY = '75i3mk2maw6ogl' SECRET_KEY = 'MDasUmDtjPbYa1I9' USER_TOKEN = '8faba2a7-e3a6-4727-b06b-a291ebbf8032' USER_SECRET = '99fde265-7fd3-4d53-8eb8-d0f6f979388c' RETURN_URL = '' authentication = linkedin.LinkedInDeveloperAuthentication( API_KEY, SECRET_KEY, USER_TOKEN, USER_SECRET, RETURN_URL, linkedin.PERMISSIONS.enums.values()) application = linkedin.LinkedInApplication(authentication) selectors = [{ 'people': [ 'first-name', 'last-name', 'headline', 'picture-url', 'public-profile-url' ] }] params = { 'keywords': job_title, 'postal-code': zip_code, 'country-code': 'us' } linked = application.search_profile(selectors=selectors, params=params) links = linked['people']['values'] results = [] #application = linkedin.LinkedInApplication(authentication) #results = application.search_profile(selectors=[{'people': ['first-name', 'last-name', 'headline']}], params={'keywords': job_title}) #res = application.search_profile(selectors=[{'people': ['first-name', 'last-name']}], params={'keywords': 'Analyst'}) #print linkedin.LinkedInApplication.search_profile.url #results = application.search_job(selectors=[{'jobs': ['id', 'customer-job-code', 'posting-date']}], params={'title': 'python', 'count': 2}) for link in links: try: results.append({ 'title': link['firstName'] + " " + link['lastName'], 'desc': link['headline'], 'image': link['pictureUrl'], 'url': link['publicProfileUrl'], 'content_type': 'Meeting', 'id': '' }) except: a = 1 return results
def get_user_auth(): RETURN_URL = '' auth = linkedin.LinkedInDeveloperAuthentication( CONSUMER_KEY, CONSUMER_SECRET, USER_TOKEN, USER_SECRET, RETURN_URL, permissions=linkedin.PERMISSIONS.enums.values()) print "(+) Authenticating to LinkedIN " app = linkedin.LinkedInApplication(auth) return app
def __init__(self): config_parser = ConfigParser.ConfigParser() config_parser.readfp(open('data/oauth.keys')) self.__consumer_key = config_parser.get('ouath-keys', 'consumer.key') self.__consumer_secret = config_parser.get('ouath-keys', 'consumer.secret') self.__user_token = config_parser.get('ouath-keys', 'user.token') self.__user_secret = config_parser.get('ouath-keys', 'user.secret') self.authentication = linkedin.LinkedInDeveloperAuthentication(self.__consumer_key, self.__consumer_secret, self.__user_token, self.__user_secret, self.__return_url, linkedin.PERMISSIONS.enums.values())
def fetch_newest_data(): authentication = linkedin.LinkedInDeveloperAuthentication( CONSUMER_KEY, CONSUMER_SECRET, USER_TOKEN, USER_SECRET, RETURN_URL, linkedin.PERMISSIONS.enums.values()) # Pass it in to the app... application = linkedin.LinkedInApplication(authentication) # Use the app.... app_data = application.get_profile(selectors=[ 'id', 'first-name', 'last-name', 'location', 'distance', 'num-connections', 'skills', 'educations', 'interests', 'honors-awards', 'num-recommenders' ]) return app_data
def get_results(job_title, zip_code, country_code): authentication = linkedin.LinkedInDeveloperAuthentication( LinkedIn.API_KEY, LinkedIn.SECRET_KEY, LinkedIn.USER_TOKEN, LinkedIn.USER_SECRET, LinkedIn.RETURN_URL, linkedin.PERMISSIONS.enums.values()) application = linkedin.LinkedInApplication(authentication) selectors = [{'people': ['first-name', 'last-name', 'headline']}] params = { 'keywords': job_title, 'postal-code': zip_code, 'country-code': country_code } results = application.search_profile(selectors=selectors, params=params) return results
def publish_post(): if not request.json or not 'profileId' or not 'message' in request.json: logging.info('Not valid request') abort(400) authentication = linkedin.LinkedInDeveloperAuthentication( os.environ['CLIENT_KEY'], os.environ['CLIENT_SECRET'], os.environ['OAUTH_TOKEN'], os.environ['OAUTH_SECRET'], os.environ['RETURN_URL'], linkedin.PERMISSIONS.enums.values()) application = linkedin.LinkedInApplication(authentication) linkedinResponse = application.submit_share(request.json['message'], None, None, None, None) if 'updateKey' in linkedinResponse and 'updateUrl' in linkedinResponse: logging.info('Post was posted') return jsonify({'status': 'Post was posted'}), 200 logging.error('Post was not posted. LinkedIn response: ' + linkedinResponse) return jsonify({'status': 'Post was not posted'}), 502
def authenticate(credential_filename): ''' Parses the credentials, authenticates on Linkedin and return the LinkedinApplication object ''' credentials = json.loads(open(credential_filename, 'r').read()) API_KEY = credentials['api_key'] API_SECRET = credentials['api_secret'] USER_TOKEN = credentials['user_token'] USER_SECRET = credentials['user_secret'] CONSUMER_KEY = credentials['api_key'] CONSUMER_SECRET = credentials['api_secret'] RETURN_URL = 'http://localhost:8000' name = credentials['name'] authentication = linkedin.LinkedInDeveloperAuthentication( CONSUMER_KEY, CONSUMER_SECRET, USER_TOKEN, USER_SECRET, RETURN_URL, linkedin.PERMISSIONS.enums.values()) application = linkedin.LinkedInApplication(authentication) print application.get_profile() return application
def __init__(self, token_set, who): self.who = who ################################# # Linked In keys # ################################# CONSUMER_KEY = token_set['CONSUMER_KEY'] CONSUMER_SECRET = token_set['CONSUMER_SECRET'] USER_TOKEN = token_set['USER_TOKEN'] USER_SECRET = token_set['USER_SECRET'] auth = linkedin.LinkedInDeveloperAuthentication( CONSUMER_KEY, CONSUMER_SECRET, USER_TOKEN, USER_SECRET, 'http://localhost', permissions=linkedin.PERMISSIONS.enums.values()) self.lnk = linkedin.LinkedInApplication(auth) self.load_linkedin_connections()
def connect(self, all_permissions=True): """ open the connection to linkedin (using the api_key and the secret_key) @param all_permissions True to get all permissions, otherwise, only public profiles @return client """ from linkedin import linkedin # permissions = linkedin.PERMISSIONS.enums.values() if all_permissions \ # else linkedin.PERMISSIONS.BASIC_PROFILE self.authentication = linkedin.LinkedInDeveloperAuthentication( self.api_key, self.secret_key, self.user_token, self.user_secret, "http://localhost:8000/", ) self.application = linkedin.LinkedInApplication(self.authentication) self.all_permissions = all_permissions return self.application
def connectLinkedin(): config = configparser.ConfigParser() config.read([os.path.expanduser('~/.rssLinkedin')]) CONSUMER_KEY = config.get("Linkedin", "CONSUMER_KEY") CONSUMER_SECRET = config.get("Linkedin", "CONSUMER_SECRET") USER_TOKEN = config.get("Linkedin", "USER_TOKEN") USER_SECRET = config.get("Linkedin", "USER_SECRET") RETURN_URL = config.get("Linkedin", "RETURN_URL"), try: authentication = linkedin.LinkedInDeveloperAuthentication( CONSUMER_KEY, CONSUMER_SECRET, USER_TOKEN, USER_SECRET, RETURN_URL, linkedin.PERMISSIONS.enums.values()) application = linkedin.LinkedInApplication(authentication) except: print("Linkedin authentication failed!\n") print("Unexpected error:", sys.exc_info()[0]) return (application)
def linkedin_group_read(): authentication = linkedin.LinkedInDeveloperAuthentication( CONSUMER_KEY, CONSUMER_SECRET, USER_TOKEN, USER_SECRET, RETURN_URL, linkedin.PERMISSIONS.enums.values()) # Pass it in to the app... application = linkedin.LinkedInApplication(authentication) # Use the app.... #app_data=application.get_profile(selectors=['id', 'first-name', 'last-name', 'location', 'distance', 'num-connections', 'skills', 'educations','interests','honors-awards','num-recommenders']) #names = [app_data['firstName'],app_data['lastName']] #print names #response = make_request(client,"http://api.linkedin.com/v1/people/~") #print response # Use the app to get group info #group_info = application.get_group(GROUP_ID) #print group_info group_posts = application.get_posts(GROUP_ID, post_ids={0}) print group_posts
@description: crawl the full profiles of given users @author: Bolun Huang """ from linkedin import linkedin import cjson import json API_KEY = "75erqo7zk5kx13" API_SECRET = "Ujr0cUJzSLksRBAB" USER_TOKEN = "161abd2a-1065-4817-80f3-c5fdcac58d8b" USER_SECRET = "e5ec9937-9cd7-4d31-b93d-bb8bfab3406f" RETURN_URL = 'http://localhost:8000' authentication = linkedin.LinkedInDeveloperAuthentication( API_KEY, API_SECRET, USER_TOKEN, USER_SECRET, RETURN_URL) application = linkedin.LinkedInApplication(authentication) profile = application.get_profile(selectors=[ 'id', 'first-name', 'last-name', 'location', 'distance', 'skills', 'educations', 'industry', 'positions', 'num-connections', 'summary', 'specialties', 'connections', 'public-profile-url' ]) print cjson.encode(profile) exit(0) f = open("../data/profiles_sample_2.json", "w") search = application.search_profile(selectors=[{ 'people': [ 'first-name', 'last-name', 'public-profile-url', 'educations',
def index(request): a = request.session['consumer'] b = request.session['oauth_token'] c = request.session['oauth_token_secret'] q = request.GET.get('oauth_verifier', 'refused') oauth_verifier = q if oauth_verifier: access_token_url = 'https://api.linkedin.com/uas/oauth/accessToken' token = oauth.Token(b, c) token.set_verifier(oauth_verifier) client = oauth.Client(a, token) resp, content = client.request(access_token_url, "POST") access_token = dict(urlparse.parse_qsl(content)) USER_TOKEN = access_token['oauth_token'] USER_SECRET = access_token['oauth_token_secret'] RETURN_URL = 'http://127.0.0.1:8000/lkdn/' auth = linkedin.LinkedInDeveloperAuthentication( consumer_key, consumer_secret, USER_TOKEN, USER_SECRET, RETURN_URL, permissions=linkedin.PERMISSIONS.enums.values()) app = linkedin.LinkedInApplication(auth) x = app.get_profile(selectors=[ 'id', 'firstName', 'lastName', 'location', 'numConnections', 'skills', 'educations', 'group_memberships', 'interests', 'positions' ]) ky = x.keys() count = 0 for i in range(len(ky)): if ky[i] == "skills": count = 1 break if count != 1: updat_dict = {'skills': "null"} x.update(updat_dict) for i in range(len(ky)): if ky[i] == "educations": count = 1 break if count != 1: updat_dict = {'educations': "null"} x.update(updat_dict) for i in range(len(ky)): if ky[i] == "location": count = 1 break if count != 1: updat_dict = {'location': "null"} x.update(updat_dict) for i in range(len(ky)): if ky[i] == "distance": count = 1 break if count != 1: updat_dict = {'distance': "null"} x.update(updat_dict) edu_key(x['educations']['values']) grplen = x['groupMemberships']['_count'] for i in range(grplen): grpid = x['groupMemberships']['values'][i]['group']['id'] grpname = x['groupMemberships']['values'][i]['group']['name'] p1 = usergroup(Userids=x['id'], groupid=grpid, groupname=grpname) p1.save(using="linkedin") p5 = groups(groupid=grpid, groupname=grpname) p5.save(using="linkedin") edulen = x['educations']['_total'] for i in range(edulen): try: deg = x['educations']['values'][i]['degree'] schl = x['educations']['values'][i]['schoolName'] eduid = x['educations']['values'][i]['id'] startDate = x['educations']['values'][i]['startDate'] endDate = x['educations']['values'][i]['endDate'] fieldofstudy = x['educations']['values'][i]['fieldOfStudy'] p2 = usereducation(Userids=x['id'], eduid=eduid, fieldofstudy=fieldofstudy, school=schl, degree=deg, startDate=startDate, endDate=endDate) p2.save(using="linkedin") except: print "sorry" skillen = x['skills']['_total'] for i in range(skillen): try: skill = x['skills']['values'][i]['skill']['name'] skillid = x['skills']['values'][i]['id'] p3 = Userskill(Userids=x['id'], skillid=skillid, skillname=skill) p3.save(using="linkedin") except: print "sorry" poslen = x['positions']['_total'] for i in range(poslen): try: compid = x['positions']['values'][i]['company']['id'] compname = x['positions']['values'][i]['company']['name'] p6 = userposition(ids=x['id'], companyid=compid, compname=compname) p6.save(using="linkedin") except: print "sorry" x1 = app.get_company_updates(compid) a = x1['values'] company_key(a) for j in range(x1['_count']): try: updateKey = x1['values'][j]['updateKey'] timestamp = x1['values'][j]['timestamp'] numLikes = x1['values'][j]['numLikes'] updatecontent = x1['values'][j]['updateContent'][ 'companyJobUpdate']['job']['description'] updatecomments = x1['values'][j]['updateComments'] p7 = company(updateKey=updateKey, updatecontent=updatecontent, companyid=compid, timestamp=timestamp, numLikes=numLikes, updatecomments=updatecomments) p7.save(using="linkedin") except: print "sorry" p5 = userprofile(firstname=x['firstName'], lastname=x['lastName'], Userids=x['id'], location=x['location'], numconnections=x['numConnections'], interests=x['interests']) p5.save(using="linkedin") return HttpResponse( "<script type='text/javascript'>d=window.open('http://www.google.com','_self');d.close();</script>" ) else: return HttpResponse( "<script type='text/javascript'>d=window.open('http://www.google.com','_self');d.close();</script>" )
def printData(fieldValues): if fieldValues != None: CONSUMER_KEY = fieldValues[0] CONSUMER_SECRET = fieldValues[1] USER_TOKEN = fieldValues[2] USER_SECRET = fieldValues[3] RETURN_URL = '' print "beginDSInfo" print """fileName;#;true csv_first_row_has_column_names;true;true; csv_separator;|;true csv_number_grouping;,;true csv_number_decimal;.;true csv_date_format;d.M.yyyy;true""" print ''.join( ['consumer_key;', str(fieldValues[0]).encode('hex'), ';true']) print ''.join( ['consumer_secret;', str(fieldValues[1]).encode('hex'), ';true']) print ''.join( ['user_token;', str(fieldValues[2]).encode('hex'), ';true']) print ''.join( ['user_secret;', str(fieldValues[3]).encode('hex'), ';true']) print "endDSInfo" print "beginData" print 'First_Name, Last_Name, Location' #try: # Instantiate the developer authentication class auth = linkedin.LinkedInDeveloperAuthentication( CONSUMER_KEY, CONSUMER_SECRET, USER_TOKEN, USER_SECRET, RETURN_URL, permissions=linkedin.PERMISSIONS.enums.values()) # Pass it in to the app... app = linkedin.LinkedInApplication(auth) try: connections = app.get_connections() except requests.ConnectionError: easygui.msgbox( 'Connection Error, Extension Doesnt Support Proxies Yet') #print connections for c in connections['values']: #if c.has_key('location')] try: print ''.join([c['firstName'].replace(',', ''), ',']), except: print ''.join(['None', ', ']), try: print ''.join([c['lastName'].replace(',', ''), ',']), except: print ''.join(['None', ', ']), try: print ''.join([c['location']['name'].replace(',', '')]) except: print ''.join(['None']) print "endData" else: print "beginDSInfo" print "endDSInfo" print "beginData" print """Error User Cancelled""" print "endData"
import datetime # Define CONSUMER_KEY, CONSUMER_SECRET, # USER_TOKEN, and USER_SECRET from the credentials # provided in your LinkedIn application # Instantiate the developer authentication class CONSUMER_KEY = "osfyhjfdnwq2" CONSUMER_SECRET = "z8WoRryNsdb8D4oh" USER_TOKEN = "1ac80d83-a372-4292-b638-540a9b66f5ce" USER_SECRET = "df56d772-a230-4e18-babf-1d567bdcbb8b" RETURN_URL = "http://localhost:8000" authentication = linkedin.LinkedInDeveloperAuthentication(CONSUMER_KEY, CONSUMER_SECRET, USER_TOKEN, USER_SECRET, RETURN_URL, linkedin.PERMISSIONS.enums.values()) # Pass it in to the app... application = linkedin.LinkedInApplication(authentication) # Use the app.... # print application.get_profile() # with open("connnections.json", "w") as outfile: # outfile.write(json.dumps(application.get_connections(), indent=1)) # # with open("memberships.json", "w") as outfile: # outfile.write(json.dumps(application.get_memberships(), indent=1)) #
def update_company_data_from_linkedin(): # Retrieves all of the company names from the job postings, # and queries LinkedIn for additional information # Define CONSUMER_KEY, CONSUMER_SECRET, # USER_TOKEN, and USER_SECRET from the credentials # provided in your LinkedIn application # Instantiate the developer authentication class authentication = linkedin.LinkedInDeveloperAuthentication(LINKEDIN_CONSUMER_KEY, LINKEDIN_CONSUMER_SECRET, LINKEDIN_OAUTH_USER_TOKEN, LINKEDIN_OAUTH_USER_SECRET, RETURN_URL, linkedin.PERMISSIONS.enums.values()) # Pass it in to the app... application = linkedin.LinkedInApplication(authentication) job_data = read_pickle('Job Data.pkl') company_list = np.unique(job_data.name.values.ravel()) # Set dict of return values and inputs comp_sels = [{'companies': ['name', 'universal-name', 'description', 'company-type', 'industries', 'status', 'employee-count-range', 'specialties', 'website-url']}] comp_params = {'keywords' : None} # Data dictionaries - going to convert them into Pandas dataframes linkedin_companies = {} linkedin_industries = {} linkedin_specialities = {} # Loop through the unique set of companies for idx, comp_name in enumerate(company_list): comp_params['keywords'] = comp_name # Set company name as keyword comp_vals = application.search_company(selectors = comp_sels, params = comp_params) if comp_vals['companies']['_total'] == 0: # No results returned continue # Calculate the edit distance between the returned results and the input name dist_vals = [] for jdx, company in enumerate(comp_vals['companies']['values']): link_comp_name = company['name'] name_dist = fuzzy_match(comp_name, link_comp_name) dist_vals.append([link_comp_name, name_dist, jdx]) # Sort the values and choose the best one sort_dist_vals = sorted(dist_vals, key=lambda s: s[1]) best_guess_company = comp_vals['companies']['values'][sort_dist_vals[0][2]] best_guess_name = sort_dist_vals[0][0] status_code, status_name = get_lnkin_code_name(best_guess_company, 'status') company_type_code, company_type_name = get_lnkin_code_name(best_guess_company, 'companyType') employee_count_code, employee_count_name = get_lnkin_code_name(best_guess_company, 'employeeCountRange') # Store company related data in a dictionary linkedin_company = {} linkedin_company['name'] = comp_name linkedin_company['lnkn_name'] = best_guess_name linkedin_company['lnkn_universal_name'] = best_guess_company.get('universalName') linkedin_company['lnkn_description'] = best_guess_company.get('description') linkedin_company['status_code'] = status_code linkedin_company['status_name'] = status_name linkedin_company['company_type_code'] = company_type_code linkedin_company['company_type_name'] = company_type_name linkedin_company['employee_count_code'] = employee_count_code linkedin_company['employee_count_name'] = employee_count_name linkedin_company['websiteUrl'] = best_guess_company.get('websiteUrl') linkedin_companies[idx] = linkedin_company # Store industry data in a separate dict if 'industries' in best_guess_company: if best_guess_company['industries']['_total'] > 0: ind_start = len(linkedin_industries) for jdx, industry in enumerate(best_guess_company['industries']['values']): linkedin_industry = {} linkedin_industry['lnkn_name'] = best_guess_name linkedin_industry['industry_type_code'] = industry['code'] linkedin_industry['industry_type_name'] = industry['name'] linkedin_industries[ind_start + jdx] = linkedin_industry # Store speciality data in a separate dict if 'specialties' in best_guess_company: if best_guess_company['specialties']['_total'] > 0: spec_start = len(linkedin_specialities) for jdx, speciality in enumerate(best_guess_company['specialties']['values']): linkedin_speciality = {} linkedin_speciality['lnkn_name'] = best_guess_name linkedin_speciality['speciality'] = speciality linkedin_specialities[spec_start + jdx] = linkedin_speciality
from linkedin import linkedin #import json #from prettytable import PrettyTable # pip install prettytable API_KEY = '78w8gcqfrt0sbn' API_SECRET = 'eLLAFinI25xkmtpG' RETURN_URL = 'http://localhost:8000' USER_TOKEN = '6a028c45-b14d-447b-b0a1-ba39044914e7' USER_SECRET = 'a2f59d06-b091-4210-b776-0828fbbd513c' auth = linkedin.LinkedInDeveloperAuthentication( API_KEY, API_SECRET, USER_TOKEN, USER_SECRET, RETURN_URL, permissions=linkedin.PERMISSIONS.enums.values()) # Pass it in to the app... app = linkedin.LinkedInApplication(auth) # Use the app... profile = app.get_profile() #profile_data = linkedin.get_profile('https://api.linkedin.com/v1/people/~?format=json') print profile
def getLinkedinJobs(search_term, start=0): # Set token and secret for LinkedIn API - OAuth 1.0 CONSUMER_KEY = '758bcqo3nipdwk' CONSUMER_SECRET = 'mUNd9c51xi5jDtlg' USER_TOKEN = 'b86af9a8-1757-42de-a8cc-60acb6f61eb9' USER_SECRET = 'af85d9ce-d082-4411-ad3b-1763e07a5ab2' RETURN_URL = 'http://localhost:8000' # Setup connection with LinkedIn authentication = linkedin.LinkedInDeveloperAuthentication( CONSUMER_KEY, CONSUMER_SECRET, USER_TOKEN, USER_SECRET, RETURN_URL, linkedin.PERMISSIONS.enums.values()) application = linkedin.LinkedInApplication(authentication) # get total number of available jobtitles total = application.search_job(params={ 'keywords': search_term, 'start': 0, 'count': 20, 'country-code': 'us' })['numResults'] # Comment above line and uncomment following line if search for specific job titles #total = application.search_job(params={'job-title': 'Data Scientist', 'start':0, 'count': 20, 'country-code':'us'})['numResults'] job_list = [] raw_job_list = [] # Retrieve job informations using LinkedIn Job Search API for i in range(0, total + 1, 20): # Retrieve 20 jobs on every call to LinkedIn Job Search API and store in a list raw_job_list = application.search_job(params={ 'keywords': search_term, 'start': 0, 'count': 20, 'country-code': 'us' }) # Comment above line and uncomment following line if search for specific job titles #raw_job_list = application.search_job(params={'job-title': 'Data Scientist', 'start':i, 'count': 20, 'country-code':'us'}) # Parse the list containing job information for job in raw_job_list['jobs']['values']: term = [] # LinkedIn Job Search API return job ID instead of Job Title term.append(job['id']) term.append(job['company']['name']) # Split location information to City and State flag = 0 if 'locationDescription' in job: location = job['locationDescription'] flag = location.find(',') if flag > 0: city = location[0:flag] state = location[flag + 2:len(location)] if flag < 0: city = location state = '' term.append(city) term.append(state) job_list.append(term) for job in job_list: job.append(get_job_title(job[0])) # Create list containing required information titles = [x[4] for x in job_list] companies = [x[1] for x in job_list] cities = [x[2] for x in job_list] states = [x[3] for x in job_list] links = [ 'http://www.linkedin.com/jobs?viewJob=&jobId=' + str(x[0]) for x in job_list ] linkedinJobs = createJobListingsDF(titles, companies, cities, states, links).drop_duplicates() return linkedinJobs
def getLinkedInApp(): auth = linkedin.LinkedInDeveloperAuthentication( api_key, secret_key, user_token, user_secret, '', linkedin.PERMISSIONS.enums.values()) return linkedin.LinkedInApplication(auth)
from linkedin import linkedin # Define CONSUMER_KEY, CONSUMER_SECRET, # USER_TOKEN, and USER_SECRET from the credentials # provided in your LinkedIn application # Instantiate the developer authentication class CONSUMER_KEY = "78vt04wpr99p9z" CONSUMER_SECRET = "kF4KQsy0gf6GfGnM" authentication = linkedin.LinkedInDeveloperAuthentication( CONSUMER_KEY, CONSUMER_SECRET, linkedin.PERMISSIONS.enums.values()) # Optionally one can send custom "state" value that will be returned from OAuth server # It can be used to track your user state or something else (it's up to you) # Be aware that this value is sent to OAuth server AS IS - make sure to encode or hash it # authorization.state = 'your_encoded_message' # Pass it in to the app... application = linkedin.LinkedInApplication(authentication) # Use the app.... application.get_profile()
__author__ = 'mtenney' from linkedin import linkedin, linkedin_keys RETURN_URL = 'http://localhost:8000' import networkx as nx from py2neo import neo4j graph = neo4j.GraphDatabaseService() g = nx.Graph() authentication = linkedin.LinkedInDeveloperAuthentication( linkedin_keys.Api_Key, linkedin_keys.Api_Secret, linkedin_keys.oAuth_Token, linkedin_keys.oAuth_Secret, RETURN_URL, linkedin.PERMISSIONS.enums.values()) application = linkedin.LinkedInApplication(authentication) application.search_profile(selectors='location', params={ u'location': { u'country': { u'code': u'ca' }, u'name': u'Toronto, Canada' } }) g.add_node('Matthew Tenney', ) connections = application.get_connections() for connection in connections['values']: n = connection['firtName'] + ' ' + connection['lastName']
# Input and output files input_file = 'linkedin-groups.csv' # Input file with group names (first column: group name; third column: group id) output_file = open('{}_linkedin-output.html'.format( datetime.datetime.fromtimestamp(current_time/1000).strftime('%Y%m%d')), 'wb') # API settings - fill in your own keys retrieved from https://www.linkedin.com/secure/developer consumer_key = '' consumer_secret = '' user_token = '' user_secret = '' return_url = 'http://www.some-random-url.org' # can be anything # API activation auth = linkedin.LinkedInDeveloperAuthentication(consumer_key, consumer_secret, user_token, user_secret, return_url, permissions=linkedin.PERMISSIONS.enums.values()) app = linkedin.LinkedInApplication(auth) # Get Linkedin groups from CSV file linkedin_group_names = [] linkedin_group_ids = [] with open(input_file, 'rb') as f: reader = csv.reader(f, delimiter=';') next(reader) for row in reader: linkedin_group_names.append(row[0]) linkedin_group_ids.append(row[2]) # Setting parameters to get for each post if date_of_comments:
def __init__(self): self.authentication = linkedin.LinkedInDeveloperAuthentication( self.CONSUMER_KEY, self.CONSUMER_SECRET, self.USER_TOKEN, self.USER_SECRET, self.RETURN_URL, linkedin.PERMISSIONS.enums.values()) self.application = linkedin.LinkedInApplication(self.authentication)
# Define CONSUMER_KEY, CONSUMER_SECRET, # USER_TOKEN, and USER_SECRET from the credentials # provided in your LinkedIn application print 'Reading keys + secrets' csv_file = csv.reader(open('auth2.0.txt', 'rb'), dialect=csv.excel_tab) keys_secrets = [] for row in csv_file: keys_secrets.append(str(row[1])) #print str(row[1]) RETURN_URL = 'http://localhost:8000' # Instantiate the developer authentication class authentication = linkedin.LinkedInDeveloperAuthentication( keys_secrets[0], keys_secrets[1], keys_secrets[2], keys_secrets[3], RETURN_URL, linkedin.PERMISSIONS.enums.values()) # Pass it in to the app... print 'Loading application.' application = linkedin.LinkedInApplication(authentication) # Use the app.... #NOTES: # api member id is different than web member id !!! # member url may have to be public 'http' not private 'https' !!! print 'Getting profiles...' #g = application.get_profile(member_url="http://www.linkedin.com/in/cianmenzeljones") #g = application.get_profile(member_url="https://www.linkedin.com/profile/view?id=104100816") #g = application.get_profile(member_id="104100816",selectors=['id', 'first-name', 'last-name','skills', 'educations'])