b0e010c6cc
Extracted from #318 (the UTF-8/doctor core, minus the env-wrapper feature): - new agent_reach/utils/process.py: utf8_subprocess_env() + mcporter_utf8_env_args() — Windows GBK consoles otherwise corrupt Chinese output from mcporter/MCP child processes - weibo/douyin/linkedin checks and weibo install/registration now pass the UTF-8 env (and register the MCP server with --env PYTHONUTF8=1) - youtube: extract _has_js_runtime_config() with an OSError guard so an unreadable yt-dlp config can't crash doctor - test_skill_command: open SKILL.md with explicit utf-8 (Windows GBK default broke these tests) Co-authored-by: chidao <2980933590@qq.com> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
46 lines
1.6 KiB
Python
46 lines
1.6 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""LinkedIn — check if linkedin-scraper-mcp is available."""
|
|
|
|
import shutil
|
|
import subprocess
|
|
|
|
from agent_reach.utils.process import utf8_subprocess_env
|
|
|
|
from .base import Channel
|
|
|
|
|
|
class LinkedInChannel(Channel):
|
|
name = "linkedin"
|
|
description = "LinkedIn 职业社交"
|
|
backends = ["linkedin-scraper-mcp", "Jina Reader"]
|
|
tier = 2
|
|
|
|
def can_handle(self, url: str) -> bool:
|
|
from urllib.parse import urlparse
|
|
return "linkedin.com" in urlparse(url).netloc.lower()
|
|
|
|
def check(self, config=None):
|
|
mcporter = shutil.which("mcporter")
|
|
if not mcporter:
|
|
return "off", (
|
|
"基本内容可通过 Jina Reader 读取。完整功能需要:\n"
|
|
" pip install linkedin-scraper-mcp\n"
|
|
" mcporter config add linkedin http://localhost:3000/mcp\n"
|
|
" 详见 https://github.com/stickerdaniel/linkedin-mcp-server"
|
|
)
|
|
try:
|
|
r = subprocess.run(
|
|
[mcporter, "config", "list"], capture_output=True,
|
|
encoding="utf-8", errors="replace", timeout=5,
|
|
env=utf8_subprocess_env(),
|
|
)
|
|
if "linkedin" in r.stdout.lower():
|
|
return "ok", "完整可用(Profile、公司、职位搜索)"
|
|
except Exception:
|
|
pass
|
|
return "off", (
|
|
"mcporter 已装但 LinkedIn MCP 未配置。运行:\n"
|
|
" pip install linkedin-scraper-mcp\n"
|
|
" mcporter config add linkedin http://localhost:3000/mcp"
|
|
)
|