Created
December 4, 2016 13:29
-
-
Save dobestan/4669492be934821c28ad9a69c6038dcc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
# In[1]: | |
# 연봉 정보 사이트 ( 크레딧잡 크롤링 ) | |
# API 주소들 ( Network > XHR 부분에서 확인해보세요! ) | |
# 자동완성 API: https://kreditjob.com/api_ver2/searchData?q=삼성 | |
# 연봉정보 API: https://kreditjob.com/api_ver2/getInfoByQueryPkNm?query=124810-삼성전자 | |
# In[2]: | |
import requests | |
# In[3]: | |
def get_related_companies(query): | |
url = "https://kreditjob.com/api_ver2/searchData?q={query}".format(query=query) | |
response = requests.get(url) | |
return [ | |
{ | |
"name": company.get("CMPN_NM"), | |
"PK_NM": company.get("PK_NM"), | |
} | |
for company | |
in response.json().get("data") | |
] | |
# In[4]: | |
get_related_companies("삼성") | |
# In[16]: | |
def get_company_average_salary(pk_nm): | |
url = "https://kreditjob.com/api_ver2/getInfoByQueryPkNm?query={query}".format(query=pk_nm) | |
response = requests.get(url) | |
return response.json().get("data")[0].get("AVG_SALARY_YY") | |
# In[17]: | |
get_company_average_salary("124810-삼성전자") | |
# In[18]: | |
def get_related_companies_salaries(query): | |
related_companies = get_related_companies(query) | |
return [ | |
{ | |
"name": related_company.get("name"), | |
"salary": get_company_average_salary(related_company.get("PK_NM")) | |
} | |
for related_company | |
in related_companies | |
] | |
# In[19]: | |
get_related_companies_salaries("삼성") | |
# In[20]: | |
get_related_companies_salaries("현대") | |
# In[ ]: | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment