arXiv 研究
透過 arXiv 的免費 REST API 搜尋並擷取學術論文。無須 API 金鑰,無須相依套件——只需 curl。
快速參考
| 操作 | 指令 |
|---|---|
| 搜尋論文 | curl "https://export.arxiv.org/api/query?search_query=all:QUERY&max_results=5" |
| 取得特定論文 | curl "https://export.arxiv.org/api/query?id_list=2402.03300" |
| 閱讀摘要 (網頁) | web_extract(urls=["https://arxiv.org/abs/2402.03300"]) |
| 閱讀全文 (PDF) | web_extract(urls=["https://arxiv.org/pdf/2402.03300"]) |
搜尋論文
API 回傳 Atom XML。可使用 grep/sed 解析,或透過 python 管道輸出為乾淨格式。
基本搜尋
curl -s "https://export.arxiv.org/api/query?search_query=all:GRPO+reinforcement+learning&max_results=5"
乾淨輸出 (將 XML 解析為可讀格式)
curl -s "https://export.arxiv.org/api/query?search_query=all:GRPO+reinforcement+learning&max_results=5&sortBy=submittedDate&sortOrder=descending" | python -c "
import sys, xml.etree.ElementTree as ET
ns = {'a': 'http://www.w3.org/2005/Atom'}
root = ET.parse(sys.stdin).getroot()
for i, entry in enumerate(root.findall('a:entry', ns)):
title = entry.find('a:title', ns).text.strip().replace('\n', ' ')
arxiv_id = entry.find('a:id', ns).text.strip().split('/abs/')[-1]
published = entry.find('a:published', ns).text[:10]
authors = ', '.join(a.find('a:name', ns).text for a in entry.findall('a:author', ns))
summary = entry.find('a:summary', ns).text.strip()[:200]
cats = ', '.join(c.get('term') for c in entry.findall('a:category', ns))
print(f'{i+1}. [{arxiv_id}] {title}')
print(f' 作者: {authors}')
print(f' 發表日期: {published} | 分類: {cats}')
print(f' 摘要: {summary}...')
print(f' PDF: https://arxiv.org/pdf/{arxiv_id}')
print()
"
搜尋查詢語法
| 前綴 | 搜尋範圍 | 範例 |
|---|---|---|
all: | 所有欄位 | all:transformer+attention |
ti: | 標題 | ti:large+language+models |
au: | 作者 | au:vaswani |
abs: | 摘要 | abs:reinforcement+learning |
cat: | 分類 | cat:cs.AI |
co: | 評論 | co:accepted+NeurIPS |
布林運算子
# AND (使用 + 時為預設)
search_query=all:transformer+attention
# OR
search_query=all:GPT+OR+all:BERT
# AND NOT
search_query=all:language+model+ANDNOT+all:vision
# 精確片語
search_query=ti:"chain+of+thought"
# 組合
search_query=au:hinton+AND+cat:cs.LG
排序與分頁
| 參數 | 選項 |
|---|---|
sortBy | relevance, lastUpdatedDate, submittedDate |
sortOrder | ascending, descending |
start | 結果偏移量 (從 0 開始) |
max_results | 結果數量 (預設 10,最多 30000) |
# 最新的 10 篇 cs.AI 論文
curl -s "https://export.arxiv.org/api/query?search_query=cat:cs.AI&sortBy=submittedDate&sortOrder=descending&max_results=10"
獲取特定論文
# 透過 arXiv ID
curl -s "https://export.arxiv.org/api/query?id_list=2402.03300"
# 多篇論文
curl -s "https://export.arxiv.org/api/query?id_list=2402.03300,2401.12345,2403.00001"
產生 BibTeX
獲取論文後,產生 BibTeX 條目:
{% raw %}
curl -s "https://export.arxiv.org/api/query?id_list=1706.03762" | python -c "
import sys, xml.etree.ElementTree as ET
ns = {'a': 'http://www.w3.org/2005/Atom', 'arxiv': 'http://arxiv.org/schemas/atom'}
root = ET.parse(sys.stdin).getroot()
entry = root.find('a:entry', ns)
if entry is None: sys.exit('找不到論文')
title = entry.find('a:title', ns).text.strip().replace('\n', ' ')
authors = ' and '.join(a.find('a:name', ns).text for a in entry.findall('a:author', ns))
year = entry.find('a:published', ns).text[:4]
raw_id = entry.find('a:id', ns).text.strip().split('/abs/')[-1]
cat = entry.find('arxiv:primary_category', ns)
primary = cat.get('term') if cat is not None else 'cs.LG'
last_name = entry.find('a:author', ns).find('a:name', ns).text.split()[-1]
print(f'@article{{{last_name}{year}_{raw_id.replace(\".\", \"\")},')
print(f' title = {{{title}}},')
print(f' author = {{{authors}}},')
print(f' year = {{{year}}},')
print(f' eprint = {{{raw_id}}},')
print(f' archivePrefix = {{arXiv}},')
print(f' primaryClass = {{{primary}}},')
print(f' url = {{https://arxiv.org/abs/{raw_id}}}')
print('}')
"
{% endraw %}
閱讀論文內容
找到論文後,閱讀它:
# 摘要頁面 (快速,包含中繼資料與摘要)
web_extract(urls=["https://arxiv.org/abs/2402.03300"])
# 全文 (PDF → 經由 Firecrawl 轉換為 Markdown)
web_extract(urls=["https://arxiv.org/pdf/2402.03300"])
如需本機 PDF 處理,請參閱 ocr-and-documents 技能。
常見分類
| 分類 | 領域 |
|---|---|
cs.AI | 人工智慧 |
cs.CL | 計算與語言 (NLP) |
cs.CV | 電腦視覺 |
cs.LG | 機器學習 |
cs.CR | 密碼學與安全 |
stat.ML | 機器學習 (統計) |
math.OC | 最佳化與控制 |
physics.comp-ph | 計算物理 |
完整列表:https://arxiv.org/category_taxonomy
輔助指令碼
scripts/search_arxiv.py 指令碼負責處理 XML 解析,並提供乾淨的輸出:
python scripts/search_arxiv.py "GRPO reinforcement learning"
python scripts/search_arxiv.py "transformer attention" --max 10 --sort date
python scripts/search_arxiv.py --author "Yann LeCun" --max 5
python scripts/search_arxiv.py --category cs.AI --sort date
python scripts/search_arxiv.py --id 2402.03300
python scripts/search_arxiv.py --id 2402.03300,2401.12345
無須相依套件——僅使用 Python 標準函式庫。
Semantic Scholar (引用、相關論文、作者個人檔案)
arXiv 不提供引用資料或推薦。請使用 Semantic Scholar API 來取得這些資料——免費,基本使用無須金鑰 (每秒 1 個請求),回傳 JSON。
取得論文詳細資料與引用次數
# 透過 arXiv ID
curl -s "https://api.semanticscholar.org/graph/v1/paper/arXiv:2402.03300?fields=title,authors,citationCount,referenceCount,influentialCitationCount,year,abstract" | python -m json.tool
# 透過 Semantic Scholar 論文 ID 或 DOI
curl -s "https://api.semanticscholar.org/graph/v1/paper/DOI:10.1234/example?fields=title,citationCount"
取得論文的引用 (誰引用了它)
curl -s "https://api.semanticscholar.org/graph/v1/paper/arXiv:2402.03300/citations?fields=title,authors,year,citationCount&limit=10" | python -m json.tool
取得論文的參考文獻 (它引用了誰)
curl -s "https://api.semanticscholar.org/graph/v1/paper/arXiv:2402.03300/references?fields=title,authors,year,citationCount&limit=10" | python -m json.tool
搜尋論文 (arXiv 搜尋的替代方案,回傳 JSON)
curl -s "https://api.semanticscholar.org/graph/v1/paper/search?query=GRPO+reinforcement+learning&limit=5&fields=title,authors,year,citationCount,externalIds" | python -m json.tool
取得論文推薦
curl -s -X POST "https://api.semanticscholar.org/recommendations/v1/papers/" \
-H "Content-Type: application/json" \
-d '{"positivePaperIds": ["arXiv:2402.03300"], "negativePaperIds": []}' | python -m json.tool
作者個人檔案
curl -s "https://api.semanticscholar.org/graph/v1/author/search?query=Yann+LeCun&fields=name,hIndex,citationCount,paperCount" | python -m json.tool
實用的 Semantic Scholar 欄位
title, authors, year, abstract, citationCount, referenceCount, influentialCitationCount, isOpenAccess, openAccessPdf, fieldsOfStudy, publicationVenue, externalIds (包含 arXiv ID、DOI 等)
完整研究流程
- 發現:
python scripts/search_arxiv.py "你的主題" --sort date --max 10 - 評估影響力:
curl -s "https://api.semanticscholar.org/graph/v1/paper/arXiv:ID?fields=citationCount,influentialCitationCount" - 閱讀摘要:
web_extract(urls=["https://arxiv.org/abs/ID"]) - 閱讀全文:
web_extract(urls=["https://arxiv.org/pdf/ID"]) - 尋找相關研究:
curl -s "https://api.semanticscholar.org/graph/v1/paper/arXiv:ID/references?fields=title,citationCount&limit=20" - 取得推薦:向 Semantic Scholar 推薦端點發送 POST 請求
- 追蹤作者:
curl -s "https://api.semanticscholar.org/graph/v1/author/search?query=NAME"
速率限制
| API | 速率 | 身分驗證 |
|---|---|---|
| arXiv | 約 1 次請求 / 3 秒 | 不需要 |
| Semantic Scholar | 1 次請求 / 秒 | 不需要 (有 API 金鑰可達 100 次/秒) |
注意事項
- arXiv 回傳 Atom XML——請使用輔助指令碼或解析程式碼片段以獲得乾淨輸出
- Semantic Scholar 回傳 JSON——可透過
python -m json.tool管道輸出以提升可讀性 - arXiv ID 格式:舊格式 (
hep-th/0601001) 與新格式 (2402.03300) - PDF:
https://arxiv.org/pdf/{id}—— 摘要:https://arxiv.org/abs/{id} - HTML (若有提供時):
https://arxiv.org/html/{id} - 如需本機 PDF 處理,請參閱
ocr-and-documents技能
ID 版本管理
arxiv.org/abs/1706.03762一律解析為最新版本arxiv.org/abs/1706.03762v1指向特定的不可變版本- 產生引用時,請保留您實際閱讀過的版本後綴,以避免引用漂移 (後續版本可能大幅更改內容)
- API
<id>欄位回傳的是包含版本號的 URL (例如http://arxiv.org/abs/1706.03762v7)
已撤稿論文
論文可能在提交後被撤銷。發生此情況時:
<summary>欄位會包含撤銷通知 (請尋找 "withdrawn" 或 "retracted")- 中繼資料欄位可能不完整
- 在將結果視為有效論文之前,務必檢查摘要