Dianel555/DSkills / skills/literature-searcher
literature-searcher
VerifiedSearch CrossRef, OpenAlex, PubMed, Semantic Scholar, and optional Scopus; deduplicate results, download open-access PDFs by DOI, classify papers, monitor new results, and analyze coverage. Use when asked to search literature, monitor a topic, download an open-access paper, classify papers, or analyze literature gaps.
| File | Kind | Size |
|---|---|---|
| .env.example | other | 743 B |
| README.md | markdown | 3.7 KB |
| SKILL.md | skill md | 2.9 KB |
| literature_searcher/__init__.py | script | 3.1 KB |
| literature_searcher/classifier.py | script | 11.2 KB |
| literature_searcher/crossref_searcher.py | script | 2.8 KB |
| literature_searcher/downloader.py | script | 5.3 KB |
| literature_searcher/insight.py | script | 6.0 KB |
| literature_searcher/monitor.py | script | 14.3 KB |
| literature_searcher/openalex_searcher.py | script | 3.0 KB |
| literature_searcher/pubmed_searcher.py | script | 6.1 KB |
| literature_searcher/scopus_searcher.py | script | 2.1 KB |
| literature_searcher/searcher.py | script | 3.4 KB |
| literature_searcher/semantic_scholar_searcher.py | script | 3.7 KB |
| monitor_config.json.template | other | 443 B |
| tests/test_literature_searcher.py | script | 9.7 KB |
| tests/test_retry_budget.py | script | 898 B |
literature_searcher/openalex_searcher.py
View on GitHub"""
OpenAlex API 搜索
"""
import json
import urllib.parse
import urllib.request
from typing import List, Optional
from . import (
OPENALEX_API, USER_AGENT, LITERATURE_EMAIL, OPENALEX_EMAIL,
OPENALEX_API_KEY, Paper, generate_random_email, reconstruct_abstract,
safe_int,
)
class OpenAlexSearcher:
"""OpenAlex API 搜索"""
@staticmethod
def search(query: str, limit: int = 20, year_from: Optional[int] = None,
year_to: Optional[int] = None) -> List[Paper]:
papers = []
try:
email = OPENALEX_EMAIL or LITERATURE_EMAIL or generate_random_email()
params = {
"search": query,
"per_page": min(limit, 200),
"mailto": email,
}
if year_from and year_to:
params["filter"] = f"publication_year:{year_from}-{year_to}"
elif year_from:
params["filter"] = f"publication_year:>{year_from - 1}"
elif year_to:
params["filter"] = f"publication_year:<{year_to + 1}"
if OPENALEX_API_KEY:
params["api_key"] = OPENALEX_API_KEY
url = f"{OPENALEX_API}/works?{urllib.parse.urlencode(params)}"
headers = {"User-Agent": USER_AGENT}
req = urllib.request.Request(url, headers=headers)
with urllib.request.urlopen(req, timeout=30) as resp:
data = json.loads(resp.read().decode("utf-8"))
for item in data.get("results", []):
doi_raw = item.get("doi", "")
doi = doi_raw.replace("https://doi.org/", "") if doi_raw else ""
authorships = item.get("authorships", [])
authors = [a.get("author", {}).get("display_name", "") for a in authorships]
authors = [a for a in authors if a]
abstract = reconstruct_abstract(item.get("abstract_inverted_index"))
year = safe_int(str(item.get("publication_year", "")))
loc = item.get("primary_location", {}) or {}
source = loc.get("source", {}) or {}
journal = source.get("display_name", "")
open_access = item.get("open_access", {}) or {}
oa_url = open_access.get("oa_url", "")
is_oa = open_access.get("is_oa", False)
issn_list = source.get("issn", []) or []
issn = issn_list[0] if issn_list else None
papers.append(Paper(
title=item.get("title", ""),
abstract=abstract,
authors=authors,
doi=doi,
year=year,
citations=item.get("cited_by_count", 0),
journal=journal,
source_platform="openalex",
is_oa=is_oa,
pdf_url=oa_url,
issn=issn,
))
except Exception as e:
print(f"[OpenAlex] 搜索错误: {e}")
return papers[:limit]
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| finishing-a-development-branchobra/superpowersUse when implementation is complete, all tests pass, and you need to decide how to integrate the work | Stars: 323k | Updated | Claude CodeCodex | Verified | Install |
| systematic-debuggingobra/superpowersUse when encountering any bug, test failure, or unexpected behavior, before proposing fixes | Stars: 323k | Updated | Claude CodeCodex | Verified | Install |
| test-driven-developmentobra/superpowersUse when implementing any feature or bugfix, before writing implementation code | Stars: 323k | Updated | Claude CodeCodex | Verified | Install |
| skill-creatoranthropics/skillsCreate new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |