본문 바로가기
공부/파이썬 Python

Emsi API 이용해서 직무 능력 불러오기 (feat. requests, json)

by 혼밥맨 2021. 1. 14.
반응형

Emsi API 이용해서 직무 능력 불러오기 (feat. requests, json)

Emsi

Emsi는 미국에 위치한 직무, 적성 분석 기업입니다. 기업에서 제공하는 API의 종류는 다양합니다. 미국 내 구인 게시물, 캐나다 내 구인 게시물, 커리어, 직업의 유망정도, 직업 별 연봉 등등 직업과 진로에 관한 다양한 정보를 제공합니다.

 

Emsi API를 이용해서 직무 능력(Job Skills)을 모두 불러오겠습니다.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# Emsi API
# https://api.emsidata.com/apis
 
# Emsi: Labor Market Anayltics
# www.economicmodeling.com
 
# Emsi Blog
# https://www.economicmodeling.com/blog/
 
# Emsi Glassdoor
# https://www.glassdoor.com/Reviews/emsi-reviews-SRCH_KE0,4.htm
 
# Getting a Emsi token API auth
# https://api.emsidata.com/guides/oauth-2-0
 
import requests
import json
from openpyxl import Workbook
 
url = "https://auth.emsicloud.com/connect/token"
 
payload = "client_id=YOUR_CLIENT_ID&client_secret=YOUR_CLIENT_SECRET&grant_type=client_credentials&scope=YOUR_SCOPE"
headers = {'content-type''application/x-www-form-urlencoded'}
 
response = requests.request("POST", url, data=payload, headers=headers)
 
print(response.text)
""" YOUR ACCESS_TOKEN """
 
# Retrieve All Skills
url = "https://skills.emsicloud.com/versions/latest/skills"
 
querystring = {"typeId":"c,h"}
 
headers = {'authorization''Bearer eyJhbGciOiJSUzI1NiIsImtpZCI6IkQ4NzM3ODcyNDdFRDFEQ0QxQTU5MkE4RDY4QUM0MUE5Q0U3MEZEQjYiLCJ0eXAiOiJKV1QiLCJ4NXQiOiIySE40Y2tmdEhjMGFXU3FOYUt4QnFjNXdfYlkifQ.eyJuYmYiOjE2MTAwOTQ0MjIsImV4cCI6MTYxMDA5ODAyMiwiaXNzIjoiaHR0cHM6Ly9hdXRoLmVtc2ljbG91ZC5jb20iLCJhdWQiOlsiaHR0cHM6Ly9hdXRoLmVtc2ljbG91ZC5jb20vcmVzb3VyY2VzIiwiZW1zaV9vcGVuIl0sImNsaWVudF9pZCI6IjV0dW4zaTY1ZnIwM2poOXIiLCJlbWFpbCI6ImpobGltQHRoZW1ham9ybWFwLmNvbSIsImNvbXBhbnkiOiJtYWpvciBtYXAiLCJuYW1lIjoiamFjb2IiLCJzY29wZSI6WyJlbXNpX29wZW4iXX0.E1PCLN91N8MEKJHcRK3vkZ4Kn44Nfq-_uW9YAOc36xd77n5MTAcuCLLBc8WhOYwCIW3LIw_IUfQMBcrkgtyxV4tPep_Nvro7I55jDHSp9DqtrijShOcbSMr7YtZpqKUkwobu0cTk7BYMO0QuPCiC-j1vA_MXkptG3-r9aL5vPfgA2PYgEpNHGY3fjhiDpB2R85kRpjl42uH_Y31hDlT_1zT-IkeqF5-EugBb2VzEU8sp3SiQY6JOKqR6cmKB_DZAxLjbTAb0bSEo_HS0XiI-iCxQEZSFZrfaxeBHkDC-Y1vXhulxpd7qeprWAVF73k8xDlHWTa5lZpolIn5oDpy2kQ'}
 
response = requests.request("GET", url, headers=headers, params=querystring)
response = json.loads(response.text)
response = str(response['skills']).split(', ')
 
print(response)
"""
["[{'type''Certification'", "'id''KS120P86XDXZJT3B7KVJ'", "'name''(American Society For Quality) ASQ Certified'}",
"""
 
 
# TEST PRINTING
for i in range(3):
  print(response[i])
 
"""
[{'type': 'Certification'
'id': 'KS120P86XDXZJT3B7KVJ'
'name': '(American Society For Quality) ASQ Certified'}
{'type': 'Hard Skill'
'id': 'KS126XS6CQCFGC3NG79X'
'name': '.NET Assemblies'}
{'type': 'Hard Skill'
'id': 'KS1200B62W5ZF38RJ7TD'
'name': '.NET Framework'}
"""
 
# .csv 포맷 엑셀 파일 작성
ABC = ["A1""B1""C1"]
columns = ["type""id""name"]
 
write_wb = Workbook()
write_ws = write_wb.active
 
# Head Column 만들기
for (alphabet, col) in zip(ABC, columns): 
  write_ws[alphabet] = col
 
# 행 단위로 추가
for t in range(0899003):
  typee = response[t][10:-1]
  id_ = response[t+1][7:-1]
  name_ = response[t+2][8:-2]
 
  write_ws.append([typee, id_, name_])
 
write_wb.save("EMSI_ALL_SKILLS.csv")
cs

EMSI_ALL_SKILLS.csv

type은 크게 Certification, Hard Skill, Soft Skill로 나누어집니다. id는 각 직무 능력에 부여되는 고유한 id입니다. 마지막으로 name은 직무능력(Job skills)의 이름입니다.

반응형

댓글