import urllib.request import json import os out_dir = "/home/admin/GBS_Research/学术论文" os.makedirs(out_dir, exist_ok=True) queries = [ "共享服务中心 价值创造", "全球商业服务 跨国企业", "财务共享 跨境 合规", "GBS 能力中心 中国", "共享服务中心 数字化转型", "共享服务中心 成本效率", ] all_papers = [] for q in queries: url = f"https://api.openalex.org/works?search={urllib.parse.quote(q)}&per_page=15&sort=cited_by_count:desc" try: req = urllib.request.Request(url, headers={"User-Agent": "Mozilla/5.0", "Accept": "application/json"}) with urllib.request.urlopen(req, timeout=30) as resp: data = json.loads(resp.read().decode()) for w in data.get("results", []): abstract_inv = w.get("abstract_inverted_index", {}) if abstract_inv: pairs = [] for word, positions in abstract_inv.items(): for pos in positions: pairs.append((pos, word)) pairs.sort() abstract = " ".join(pw for _, pw in pairs) else: abstract = "" all_papers.append({ "title": w.get("title", ""), "doi": w.get("doi", ""), "year": w.get("publication_year", ""), "cited_by_count": w.get("cited_by_count", 0), "authors": [a.get("author",{}).get("display_name","") for a in w.get("authorships",[])], "source": w.get("primary_location",{}).get("source",{}).get("display_name","") if w.get("primary_location") else "", "abstract": abstract, "query": q, "language": w.get("language",""), }) print(f"✓ CN {q}: {data.get('meta',{}).get('count',0)} total") except Exception as e: print(f"✗ CN {q}: {e}") # Deduplicate by DOI seen = set() unique = [] for p in all_papers: key = p["doi"] or p["title"] if key not in seen: seen.add(key) unique.append(p) unique.sort(key=lambda x: x.get("cited_by_count",0), reverse=True) # Save lines = ["# 中文学术论文汇总 (OpenAlex搜索)\n"] lines.append(f"共找到 {len(unique)} 篇不重复论文\n") lines.append("| # | 标题 | 年份 | 被引 | 语言 | DOI |") lines.append("|---|------|------|------|------|-----|") for i, p in enumerate(unique[:80], 1): title = p["title"][:80] if p["title"] else "N/A" doi_link = f"https://doi.org/{p['doi'].replace('https://doi.org/','')}" if p["doi"] else "" lines.append(f"| {i} | {title} | {p['year']} | {p['cited_by_count']} | {p['language']} | {doi_link} |") lines.append("\n---\n## 详细信息\n") for i, p in enumerate(unique[:80], 1): lines.append(f"### {i}. {p['title']}") lines.append(f"- **年份**: {p['year']} | **被引**: {p['cited_by_count']} | **语言**: {p['language']}") lines.append(f"- **期刊**: {p['source']}") lines.append(f"- **作者**: {', '.join(p['authors'][:5])}") lines.append(f"- **DOI**: {p['doi']}") lines.append(f"- **摘要**: {p['abstract'][:500]}") lines.append("") with open(f"{out_dir}/chinese_papers.md", "w", encoding="utf-8") as f: f.write("\n".join(lines)) with open(f"{out_dir}/chinese_papers.json", "w", encoding="utf-8") as f: json.dump(unique, f, ensure_ascii=False, indent=2) print(f"\n中文学术论文总数: {len(unique)}")