You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

关于借助LinkedIn API获取人才档案信息的技术咨询

LinkedIn API 提取个人资料相关问题解答

能否通过API提取目标信息?

可以,但需严格遵守LinkedIn的API使用规范和数据隐私政策。你提到的姓名、个人简介、所在地属于基础公开资料(需对应权限),工作经历、教育背景属于更详细的个人数据,需要获取对应的API权限才能访问,且通常需要被查询用户的授权。


1. 注册成为LinkedIn开发者

  • 用现有LinkedIn账号登录LinkedIn开发者平台
  • 填写开发者信息,包括你的身份(个人/企业)、应用的使用场景说明,提交后等待审核(一般1-2个工作日内通过)
  • 审核通过后,创建新应用,即可获取Client ID和Client Secret,这是后续调用API的核心凭证

2. 获取提取信息的足够权限

  • LinkedIn API采用权限范围(Scopes)控制数据访问:
    • 基础资料(姓名、简介、所在地):需要申请r_liteprofile权限,这个权限默认可申请,无需额外审批
    • 工作经历、教育背景:需要申请r_fullprofile权限,该权限需提交详细的用途说明,证明你的系统符合LinkedIn的API政策(比如非商业爬取、仅用于合法的人才招聘或个人数据分析等),等待LinkedIn团队审批
  • 所有权限申请必须明确说明数据使用目的,禁止用于未经授权的数据收集、售卖或其他违规用途

3. 编写实现流程的脚本

以下以Python为例,给出核心流程:

  1. 实现OAuth2授权流程
    首先引导用户完成授权,获取授权码,再兑换成访问令牌(Access Token):
    import requests
    
    # 替换为你的应用凭证
    CLIENT_ID = "your_client_id"
    CLIENT_SECRET = "your_client_secret"
    REDIRECT_URI = "your_redirect_uri" # 需在开发者平台提前配置
    
    # 第一步:获取授权码(需用户在浏览器中完成授权)
    auth_url = f"https://www.linkedin.com/oauth/v2/authorization?response_type=code&client_id={CLIENT_ID}&redirect_uri={REDIRECT_URI}&scope=r_liteprofile%20r_fullprofile"
    print("请访问以下链接完成授权:", auth_url)
    code = input("输入授权码:")
    
    # 第二步:兑换Access Token
    token_url = "https://www.linkedin.com/oauth/v2/accessToken"
    token_data = {
        "grant_type": "authorization_code",
        "code": code,
        "redirect_uri": REDIRECT_URI,
        "client_id": CLIENT_ID,
        "client_secret": CLIENT_SECRET
    }
    token_response = requests.post(token_url, data=token_data)
    access_token = token_response.json()["access_token"]
    
  2. 调用API提取数据
    使用获取到的Access Token调用对应API端点:
    headers = {"Authorization": f"Bearer {access_token}"}
    
    # 获取基础资料(姓名、简介、所在地)
    profile_url = "https://api.linkedin.com/v2/me"
    profile_response = requests.get(profile_url, headers=headers)
    profile_data = profile_response.json()
    name = f"{profile_data['localizedFirstName']} {profile_data['localizedLastName']}"
    headline = profile_data.get("headline", "")
    location = profile_data.get("location", {}).get("localizedName", "")
    
    # 获取工作经历
    positions_url = "https://api.linkedin.com/v2/positions"
    positions_response = requests.get(positions_url, headers=headers)
    work_experience = positions_response.json().get("elements", [])
    
    # 获取教育背景
    educations_url = "https://api.linkedin.com/v2/educations"
    educations_response = requests.get(educations_url, headers=headers)
    education_background = educations_response.json().get("elements", [])
    
    # 整理输出
    output = {
        "姓名": name,
        "个人简介": headline,
        "所在地": location,
        "工作经历": work_experience,
        "教育背景": education_background
    }
    print(output)
    
  3. 注意事项
    • 遵守LinkedIn的API速率限制,避免短时间内大量调用导致账号被限流
    • 处理API返回的错误信息,比如权限不足、令牌过期等情况
    • 确保用户数据的存储和使用符合隐私法规(如GDPR、CCPA)

内容的提问来源于stack exchange,提问作者Chihiro Fukazawa

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.24 12:52:39