papersearch 0.6.3 → 0.6.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +11 -19
- package/README.md +11 -19
- package/dist/capabilities/pdf-discovery/school/SchoolMcpClient.js +1 -1
- package/package.json +1 -1
- package/school/paper_search_school/adapters/base.py +3 -2
- package/school/paper_search_school/adapters/elsevier/__init__.py +46 -0
- package/school/paper_search_school/engine/batch_institution.py +99 -5
- package/school/paper_search_school/engine/batch_login.py +18 -5
- package/school/paper_search_school/federations/builtin/azsciencenet.json +11 -0
- package/school/paper_search_school/federations/builtin/belnet.json +11 -0
- package/school/paper_search_school/federations/builtin/cstcloud.json +11 -0
- package/school/paper_search_school/federations/builtin/cynet.json +11 -0
- package/school/paper_search_school/federations/builtin/edugate.json +11 -0
- package/school/paper_search_school/federations/builtin/eduidlu.json +11 -0
- package/school/paper_search_school/federations/builtin/irfed.json +11 -0
- package/school/paper_search_school/federations/builtin/iucc.json +11 -0
- package/school/paper_search_school/federations/builtin/maeen.json +11 -0
- package/school/paper_search_school/federations/builtin/renater.json +11 -0
- package/school/paper_search_school/federations/builtin/surfconext.json +11 -0
- package/school/paper_search_school/federations/builtin/ukfederation.json +11 -0
- package/school/paper_search_school/federations/schools.py +68 -14
- package/skills/paper-search/SKILL.md +1 -1
- package/skills/paper-search/references/federation-support.md +84 -11
- package/skills/paper-search/references/school-setup.md +3 -2
package/README.en.md
CHANGED
|
@@ -133,27 +133,19 @@ Papers the open channels cannot get can come through your school's subscriptions
|
|
|
133
133
|
1. Through the federations interconnected via [eduGAIN](https://edugain.org/), such as CARSI in China, HKAF in Hong Kong and SGAF in Singapore;
|
|
134
134
|
2. Schools in no national federation that have [OpenAthens](https://www.openathens.net/) access can sign in through it as well.
|
|
135
135
|
|
|
136
|
-
**Supported academic identity federations** (
|
|
136
|
+
**Supported academic identity federations** (by continent and region)
|
|
137
137
|
|
|
138
|
-
|
|
|
138
|
+
| Continent | Region | Supported (place: federation) |
|
|
139
139
|
|---|---|---|
|
|
140
|
-
| Chinese mainland, Macau
|
|
141
|
-
|
|
|
142
|
-
|
|
|
143
|
-
|
|
|
144
|
-
|
|
|
145
|
-
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
| Bangladesh | TIGERfed | Trust, Identity and Group management for Education and Research Federation |
|
|
150
|
-
| Pakistan | PKIFED | Pakistan Identity Federation |
|
|
151
|
-
| Oman | OMREN | OMREN Identity Federation |
|
|
152
|
-
| United States | InCommon | InCommon Federation |
|
|
153
|
-
| Schools in no national federation (most universities in Southeast Asia and others) | OpenAthens | OpenAthens institutional sign-in |
|
|
154
|
-
|
|
155
|
-
- What each federation supports: [federation support table](skills/paper-search/references/federation-support.md) (Chinese).
|
|
156
|
-
- Planned: the UK (UK federation), Australia (AAF) and the federations of European countries, then the other countries in eduGAIN; see the [roadmap](docs/ROADMAP.zh.md) (Chinese).
|
|
140
|
+
| Asia | East Asia | Chinese mainland, Macau: CARSI; research institutions in the Chinese mainland: CSTCloud; Hong Kong: HKAF; Japan: GakuNin; South Korea: KAFE; Taiwan: through OpenAthens |
|
|
141
|
+
| Asia | Southeast Asia | Singapore: SGAF; Malaysia: SIFULAN; Thailand, the Philippines and others: through OpenAthens |
|
|
142
|
+
| Asia | South Asia | India: INFED; Sri Lanka: LIAF; Bangladesh: TIGERfed; Pakistan: PKIFED |
|
|
143
|
+
| Asia | West Asia | Turkey: YETKİM; Saudi Arabia: Maeen; Cyprus: CyNet; Israel: IUCC; Iran: IRFED; Azerbaijan: AzScienceNet; Oman: OMREN |
|
|
144
|
+
| Europe | Western Europe | United Kingdom: UK federation; Ireland: Edugate; France: RENATER; Netherlands: SURFconext; Belgium: Belnet; Luxembourg: eduID Luxembourg |
|
|
145
|
+
| Americas | North America | United States: InCommon |
|
|
146
|
+
|
|
147
|
+
- Full names, school counts and tested schools of each federation: [federation support table](skills/paper-search/references/federation-support.md) (Chinese).
|
|
148
|
+
- Planned, in this order: the rest of Europe (Northern, Central, Southern, Eastern), the Americas (Canada, then Latin America and the Caribbean), Oceania, and Africa last; see the [roadmap](docs/ROADMAP.zh.md) (Chinese).
|
|
157
149
|
|
|
158
150
|
- **Your school account is enough**: no keys to apply for; publisher API keys only cover Elsevier and Springer.
|
|
159
151
|
- **Deep publisher adaptation**: the general download flow is deeply optimized, and more than 30 publishers have dedicated rules, one by one: where the institutional login is and how to fetch the PDF and supplementary files follow each publisher as it really is, so downloads are more accurate and fewer papers are missed. The main publishers:
|
package/README.md
CHANGED
|
@@ -133,27 +133,19 @@ AI 会先问你要不要装 PaperSearch 的命令行程序,你同意后装好
|
|
|
133
133
|
1.通过 [eduGAIN](https://edugain.org/) 互联,如中国CARSI、香港HKAF,新加坡SGAF等;
|
|
134
134
|
2.没有加入本国联盟的学校,有 [OpenAthens](https://www.openathens.net/) 权限的,也能经它登录。
|
|
135
135
|
|
|
136
|
-
|
|
136
|
+
**支持的学术身份联盟**(按大洲和区域)
|
|
137
137
|
|
|
138
|
-
|
|
|
138
|
+
| 大洲 | 区域 | 已支持(地区:联盟) |
|
|
139
139
|
|---|---|---|
|
|
140
|
-
|
|
|
141
|
-
|
|
|
142
|
-
|
|
|
143
|
-
|
|
|
144
|
-
|
|
|
145
|
-
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
| 孟加拉 | TIGERfed | Trust, Identity and Group management for Education and Research Federation |
|
|
150
|
-
| 巴基斯坦 | PKIFED | Pakistan Identity Federation |
|
|
151
|
-
| 阿曼 | OMREN | OMREN Identity Federation |
|
|
152
|
-
| 美国 | InCommon | InCommon Federation |
|
|
153
|
-
| 未加入本国联盟的学校(东南亚多数大学等) | OpenAthens | OpenAthens 机构登录服务 |
|
|
154
|
-
|
|
155
|
-
- 每个联盟的支持情况,见 [学术联盟支持表](skills/paper-search/references/federation-support.md)。
|
|
156
|
-
- 计划中:英国(UK federation)、澳大利亚(AAF)、欧洲各国联盟,之后是 eduGAIN 里的其他国家,见 [路线图](docs/ROADMAP.zh.md)。
|
|
140
|
+
| 亚洲 | 东亚 | 中国内地、澳门:CARSI;中国内地科研机构:CSTCloud(中国科技云联盟);香港:HKAF;日本:GakuNin(学認);韩国:KAFE;台湾:经 OpenAthens |
|
|
141
|
+
| 亚洲 | 东南亚 | 新加坡:SGAF;马来西亚:SIFULAN;泰国、菲律宾等:经 OpenAthens |
|
|
142
|
+
| 亚洲 | 南亚 | 印度:INFED;斯里兰卡:LIAF;孟加拉:TIGERfed;巴基斯坦:PKIFED |
|
|
143
|
+
| 亚洲 | 西亚 | 土耳其:YETKİM;沙特阿拉伯:Maeen;塞浦路斯:CyNet;以色列:IUCC;伊朗:IRFED;阿塞拜疆:AzScienceNet;阿曼:OMREN |
|
|
144
|
+
| 欧洲 | 西欧 | 英国:UK federation;爱尔兰:Edugate;法国:RENATER;荷兰:SURFconext;比利时:Belnet;卢森堡:eduID Luxembourg |
|
|
145
|
+
| 美洲 | 北美洲 | 美国:InCommon |
|
|
146
|
+
|
|
147
|
+
- 各联盟的全称、学校数和实测过的学校,见 [学术联盟支持表](skills/paper-search/references/federation-support.md)。
|
|
148
|
+
- 计划中,按这个顺序推进:欧洲其余地区(北欧、中欧、南欧、东欧)、美洲(加拿大,再拉丁美洲和加勒比)、大洋洲,最后非洲,见 [路线图](docs/ROADMAP.zh.md)。
|
|
157
149
|
|
|
158
150
|
- **学校账号就能用**:不用另外申请 key;出版社 API key 只覆盖 Elsevier、Springer 两家。
|
|
159
151
|
- **深度适配出版社**:深度优化了下载的通用流程,并且针对 30 多家出版社逐家写了专门规则,机构登录入口在哪、PDF 和补充材料怎么取,都按各自出版社的实际情况来,下载更准、更少漏篇。优化的出版社主要有:
|
|
@@ -20,7 +20,7 @@ export const SCHOOL_DOWNLOAD_TIMEOUT_MS = 1_200_000;
|
|
|
20
20
|
export const SCHOOL_CLEANUP_TIMEOUT_MS = 5_000;
|
|
21
21
|
const SCHOOL_BACKEND_SOURCE = "school";
|
|
22
22
|
// MCP clientInfo is informational only; keep in step with package.json on release.
|
|
23
|
-
const PAPER_SEARCH_MCP_CLIENT_VERSION = "0.6.
|
|
23
|
+
const PAPER_SEARCH_MCP_CLIENT_VERSION = "0.6.4";
|
|
24
24
|
const NO_BATCH_SUPPORT = {
|
|
25
25
|
downloadFields: false,
|
|
26
26
|
supplementsField: false,
|
package/package.json
CHANGED
|
@@ -242,8 +242,9 @@ class PublisherAdapter:
|
|
|
242
242
|
return None
|
|
243
243
|
|
|
244
244
|
def leave_email_step(self, page: Any, result: Any) -> bool:
|
|
245
|
-
"""The publisher's sign-in asks for the user's work email, not the school
|
|
246
|
-
|
|
245
|
+
"""The publisher's sign-in asks for the user's work email, not the school, or
|
|
246
|
+
offers only another school chosen before in this browser: go back to its
|
|
247
|
+
school search before anything is typed; True when clicked."""
|
|
247
248
|
return False
|
|
248
249
|
|
|
249
250
|
def prepare_institution_choice(self, page: Any, result: Any) -> bool | None:
|
|
@@ -86,6 +86,27 @@ _EMAIL_STEP_JS = """() => {
|
|
|
86
86
|
return true;
|
|
87
87
|
}"""
|
|
88
88
|
|
|
89
|
+
# Elsevier ID's "Access through your organization – You will be sent to <school>"
|
|
90
|
+
# for a school chosen before in this browser, with "Try Another way" to its search:
|
|
91
|
+
# the school shown, when the page is that one (2026-11-13: it named the previous
|
|
92
|
+
# school and no other could be chosen there).
|
|
93
|
+
_REMEMBERED_JS = """() => {
|
|
94
|
+
const shown = (el) => !!el && el.getClientRects().length > 0;
|
|
95
|
+
const another = [...document.querySelectorAll("#bdd-elsSecondaryBtn-tryAnotherWay, #bdd-elsSecondaryBtn")]
|
|
96
|
+
.find((el) => shown(el) && /try another way/i.test(el.textContent || ""));
|
|
97
|
+
const body = (document.body && document.body.innerText) || "";
|
|
98
|
+
if (!another || !/you will be sent to/i.test(body)) return null;
|
|
99
|
+
const school = [...document.querySelectorAll("#bdd-elsPrimaryBtn .els-institution-group, #bdd-elsPrimaryBtn")].find(shown);
|
|
100
|
+
return {school: ((school && (school.innerText || school.textContent)) || "").replace(/\\s+/g, " ").trim()};
|
|
101
|
+
}"""
|
|
102
|
+
_TRY_ANOTHER_JS = """() => {
|
|
103
|
+
const el = [...document.querySelectorAll("#bdd-elsSecondaryBtn-tryAnotherWay, #bdd-elsSecondaryBtn")]
|
|
104
|
+
.find((el) => el.getClientRects().length > 0 && /try another way/i.test(el.textContent || ""));
|
|
105
|
+
if (!el) return false;
|
|
106
|
+
el.click();
|
|
107
|
+
return true;
|
|
108
|
+
}"""
|
|
109
|
+
|
|
89
110
|
_ENTRY_JS = """
|
|
90
111
|
({manualSelection, institutionQuery}) => {
|
|
91
112
|
const visible = (el) => {
|
|
@@ -281,6 +302,31 @@ class ElsevierAdapter(PublisherAdapter):
|
|
|
281
302
|
return False # the page moved on while it was read
|
|
282
303
|
if clicked:
|
|
283
304
|
self.d._event(result, "elsevier_email_step_left", "Access via another organization")
|
|
305
|
+
return True
|
|
306
|
+
return self._leave_remembered_other_school(page, result)
|
|
307
|
+
|
|
308
|
+
def _leave_remembered_other_school(self, page: Any, result: Any) -> bool:
|
|
309
|
+
"""Elsevier ID offers only a school chosen before in this browser (``_REMEMBERED_JS``):
|
|
310
|
+
when it is not the configured school, "Try Another way" goes to the search.
|
|
311
|
+
The configured school's own page, and any page with no school configured,
|
|
312
|
+
stay as they are."""
|
|
313
|
+
names = [n for n in self.d._institution_names() if n]
|
|
314
|
+
if not names:
|
|
315
|
+
return False
|
|
316
|
+
try:
|
|
317
|
+
shown = page.evaluate(_REMEMBERED_JS)
|
|
318
|
+
if not isinstance(shown, dict) or not shown.get("school"):
|
|
319
|
+
return False
|
|
320
|
+
key = lambda text: re.sub(r"[\W_]+", "", str(text or "").casefold())
|
|
321
|
+
if any(key(name) and key(name) in key(shown["school"]) for name in names):
|
|
322
|
+
return False
|
|
323
|
+
clicked = page.evaluate(_TRY_ANOTHER_JS) is True
|
|
324
|
+
except Exception as exc:
|
|
325
|
+
if not is_driver_error(exc):
|
|
326
|
+
raise
|
|
327
|
+
return False # the page moved on while it was read
|
|
328
|
+
if clicked:
|
|
329
|
+
self.d._event(result, "elsevier_remembered_school_left", f"{shown['school'][:120]}: not the configured school")
|
|
284
330
|
return clicked
|
|
285
331
|
|
|
286
332
|
def is_redirect_page(self, url: str) -> bool:
|
|
@@ -603,7 +603,8 @@ class InstitutionMixin:
|
|
|
603
603
|
|
|
604
604
|
# Words a unit of the school itself may add to its name (its library, campus,
|
|
605
605
|
# hospital): such an entry may be the school's, so the search settles nothing.
|
|
606
|
-
|
|
606
|
+
# A campus by its own name too ("<school> - Campus <name>", 2026-11-13).
|
|
607
|
+
_OWN_UNIT = re.compile(r"^(?:graduate school|school of|faculty of|department of|institute of|cent(?:er|re) for|campus)\b"
|
|
607
608
|
r"|^(?:(?:the|main|central|university|univ|library|libraries|campus|branch|hospital|"
|
|
608
609
|
r"medical|medicine|dentistry|nursing|pharmacy|law|business|graduate|department|"
|
|
609
610
|
r"health|engineering|center|centre|faculty|school|college|of|and)\b\s*)+$")
|
|
@@ -615,6 +616,8 @@ class InstitutionMixin:
|
|
|
615
616
|
r"没有找到|无结果|未找到|找不到(?:相关|匹配)", re.I)
|
|
616
617
|
# How long the results must stay the same before they settle the school's absence.
|
|
617
618
|
SEARCH_SETTLED_SEC = 4
|
|
619
|
+
# Entries enough to be a search's results, not a page's own links.
|
|
620
|
+
UNRELATED_RESULTS = 3
|
|
618
621
|
|
|
619
622
|
def _search_lists_no_school(self, page: Any, result: DownloadResult, url: str, scored: list) -> bool:
|
|
620
623
|
"""The school's name was searched on this page, the results are shown and
|
|
@@ -637,6 +640,7 @@ class InstitutionMixin:
|
|
|
637
640
|
residues = [self._name_residue(" ".join(o.translate(self._QUOTES).split()).lower()) for o in may_sign_in]
|
|
638
641
|
if any(r is not None and self._OWN_UNIT.match(r) for r in residues):
|
|
639
642
|
return False # perhaps the school's own library or campus: left to the user
|
|
643
|
+
settled = self.SEARCH_SETTLED_SEC
|
|
640
644
|
if others:
|
|
641
645
|
evidence = f"{len(others)} other entries: " + "; ".join(others[:3])
|
|
642
646
|
else:
|
|
@@ -646,21 +650,105 @@ class InstitutionMixin:
|
|
|
646
650
|
if not _is_browser_error(exc):
|
|
647
651
|
raise
|
|
648
652
|
return False
|
|
649
|
-
|
|
653
|
+
baseline = getattr(result, "_search_baseline", None)
|
|
654
|
+
before = baseline[1] if isinstance(baseline, tuple) and baseline[0] == url else set()
|
|
655
|
+
# Only what the search added: the page's own links listed before it are no results
|
|
656
|
+
# (2026-11-13: "About Elsevier", "Cookie settings" ended four searches still loading).
|
|
657
|
+
unrelated = sorted({str(it.get("t") or "")[:60] for score, it in scored if score == 0
|
|
658
|
+
and str(it.get("t") or "").strip() and str(it.get("t") or "")[:60] not in before})
|
|
659
|
+
if said:
|
|
660
|
+
evidence = f'"{said.group(0)}"'
|
|
661
|
+
elif len(unrelated) >= self.UNRELATED_RESULTS and not self._search_list_closed(page, result, url):
|
|
662
|
+
# A fuzzy search listing only schools of other names, none carrying
|
|
663
|
+
# the school's entityID (2026-11-13: "University of <town>" for one
|
|
664
|
+
# school, 20 of them): longer, a slow search may still be replacing them.
|
|
665
|
+
evidence, settled = f"{len(unrelated)} unrelated entries: " + "; ".join(unrelated[:3]), 2 * settled
|
|
666
|
+
else:
|
|
650
667
|
return False # results not shown yet: looked at again next pass
|
|
651
|
-
evidence = f'"{said.group(0)}"'
|
|
652
668
|
now = time.time()
|
|
653
669
|
seen = getattr(result, "_search_miss", None)
|
|
654
670
|
if not seen or seen[0] != url or seen[1] != evidence:
|
|
655
671
|
result._search_miss = (url, evidence, now)
|
|
656
672
|
return False
|
|
657
|
-
if now - seen[2] <
|
|
673
|
+
if now - seen[2] < settled:
|
|
658
674
|
return False
|
|
659
675
|
self._event(result, "auto_institution_not_found",
|
|
660
676
|
f"{self.institution_query} (search: {evidence[:160]}) @ {url}")
|
|
661
677
|
result._institution_not_listed = True
|
|
662
678
|
return True
|
|
663
679
|
|
|
680
|
+
# How long a search by one of the school's names may show nothing before the next is typed.
|
|
681
|
+
SEARCH_RETRY_SEC = 6
|
|
682
|
+
|
|
683
|
+
def _search_queries(self, names: list[str]) -> list[str]:
|
|
684
|
+
"""The school's names to search by, in Latin letters first (straight apostrophes)."""
|
|
685
|
+
typed = [n.translate(self._QUOTES) for n in names]
|
|
686
|
+
return list(dict.fromkeys([q for q in typed if q.isascii()] + [q for q in typed if not q.isascii()]))
|
|
687
|
+
|
|
688
|
+
def _search_again_by_another_name(self, page: Any, result: DownloadResult, url: str, names: list[str]) -> bool:
|
|
689
|
+
"""The search by one of the school's names has shown nothing for
|
|
690
|
+
``SEARCH_RETRY_SEC`` (its list closed, or no entry beyond the page's own):
|
|
691
|
+
the box is cleared and the next name typed, once each (2026-11-13: a school
|
|
692
|
+
listed by its French name, searched by its English one, found nothing).
|
|
693
|
+
A box holding anything but our own query is the user's and stays."""
|
|
694
|
+
box_at = getattr(result, "_search_box", None)
|
|
695
|
+
if (not isinstance(box_at, tuple) or box_at[0] != url
|
|
696
|
+
or time.time() - float(getattr(result, "_search_typed_at", 0) or 0) < self.SEARCH_RETRY_SEC):
|
|
697
|
+
return False
|
|
698
|
+
tried = []
|
|
699
|
+
for event in result.events:
|
|
700
|
+
query, _, where = str(event.get("detail", "")).partition(" @ ")
|
|
701
|
+
if event["state"] == "auto_institution_search" and len(where) > 10 and url.startswith(where):
|
|
702
|
+
tried.append(query)
|
|
703
|
+
left = [q for q in self._search_queries(names) if q not in tried]
|
|
704
|
+
if not left:
|
|
705
|
+
return False
|
|
706
|
+
baseline = getattr(result, "_search_baseline", None)
|
|
707
|
+
before = baseline[1] if isinstance(baseline, tuple) and baseline[0] == url else set()
|
|
708
|
+
if not self._search_list_closed(page, result, url) and self._entry_texts(page) - before:
|
|
709
|
+
return False # results shown: they decide
|
|
710
|
+
box = page.locator(box_at[1]).first
|
|
711
|
+
try:
|
|
712
|
+
if str(box.input_value(timeout=2_000) or "").strip() not in tried:
|
|
713
|
+
return False
|
|
714
|
+
box.fill("")
|
|
715
|
+
box.press_sequentially(left[0], delay=40)
|
|
716
|
+
except Exception as exc:
|
|
717
|
+
if not _is_browser_error(exc):
|
|
718
|
+
raise
|
|
719
|
+
return False
|
|
720
|
+
result._search_typed_at = time.time()
|
|
721
|
+
result._search_miss = None
|
|
722
|
+
self._event(result, "auto_institution_search", f"{left[0]} @ {url}")
|
|
723
|
+
return True
|
|
724
|
+
|
|
725
|
+
def _search_list_closed(self, page: Any, result: DownloadResult, url: str) -> bool:
|
|
726
|
+
"""The search box typed in says its list is closed (``aria-expanded="false"``):
|
|
727
|
+
no results are shown, whatever else the page lists (2026-11-13: a search
|
|
728
|
+
showing nothing, its page's links taken for results)."""
|
|
729
|
+
box = getattr(result, "_search_box", None)
|
|
730
|
+
if not isinstance(box, tuple) or box[0] != url:
|
|
731
|
+
return False
|
|
732
|
+
try:
|
|
733
|
+
return page.evaluate("""(selector) => {
|
|
734
|
+
const el = document.querySelector(selector);
|
|
735
|
+
return !!el && el.getAttribute('aria-expanded') === 'false';
|
|
736
|
+
}""", box[1]) is True
|
|
737
|
+
except Exception as exc:
|
|
738
|
+
if not _is_browser_error(exc):
|
|
739
|
+
raise
|
|
740
|
+
return True # not readable now: nothing concluded from it
|
|
741
|
+
|
|
742
|
+
def _entry_texts(self, page: Any) -> set[str]:
|
|
743
|
+
"""The entries a page lists now, by their text (``_ENTRIES_JS``)."""
|
|
744
|
+
try:
|
|
745
|
+
items = page.evaluate(self._ENTRIES_JS, self._ENTRY_SELECTOR)
|
|
746
|
+
except Exception as exc:
|
|
747
|
+
if not _is_browser_error(exc):
|
|
748
|
+
raise
|
|
749
|
+
return set()
|
|
750
|
+
return {str(it.get("t") or "")[:60] for it in items if isinstance(it, dict)} if isinstance(items, list) else set()
|
|
751
|
+
|
|
664
752
|
def _click_unique_institution_entry(self, page: Any, result: DownloadResult, url: str) -> bool:
|
|
665
753
|
"""Click the single best visible entry for the configured school.
|
|
666
754
|
|
|
@@ -939,6 +1027,8 @@ class InstitutionMixin:
|
|
|
939
1027
|
# never on a verification page, which the challenge wait takes first: a
|
|
940
1028
|
# search there found no school and ended the login (fixture, 2026-11-01).
|
|
941
1029
|
if not once("institution_search"):
|
|
1030
|
+
if self._search_again_by_another_name(page, result, url, names):
|
|
1031
|
+
return True
|
|
942
1032
|
return self._handle_institution_search_miss(page, result, url)
|
|
943
1033
|
if not self._is_challenge_page(page):
|
|
944
1034
|
if self._assist_federation_discovery(page, result):
|
|
@@ -952,7 +1042,11 @@ class InstitutionMixin:
|
|
|
952
1042
|
if str(box.input_value(timeout=2_000) or "").strip():
|
|
953
1043
|
return False # the user is typing; never replace it
|
|
954
1044
|
# The English name, with a straight apostrophe (CARSI writes "Xi’an", 2026-11-01).
|
|
955
|
-
query =
|
|
1045
|
+
query = self._search_queries(names)[0]
|
|
1046
|
+
# What the page lists before the search (its own links): no result of it.
|
|
1047
|
+
result._search_baseline = (url, self._entry_texts(page))
|
|
1048
|
+
result._search_box = (url, selector)
|
|
1049
|
+
result._search_typed_at = time.time()
|
|
956
1050
|
# Key by key: search-as-you-type lists (SAMS Sigma, OpenAthens)
|
|
957
1051
|
# do not search on a filled value (2026-11-01).
|
|
958
1052
|
box.press_sequentially(query, delay=40)
|
|
@@ -578,9 +578,10 @@ class LoginMixin:
|
|
|
578
578
|
_IDP_CONFIRMATION_JS = """() => document.querySelector('[name="_eventId_TermsRejected"]') ? 'terms-of-use'
|
|
579
579
|
: document.querySelector('[name="_shib_idp_consentOptions"], [name="_shib_idp_consentIds"]') ? 'attribute-release' : ''"""
|
|
580
580
|
# Shibboleth's "Message Security Error": the identity provider could not trust the
|
|
581
|
-
# publisher's request (a school's IdP to Elsevier, 2026-11-12)
|
|
581
|
+
# publisher's request (a school's IdP to Elsevier, 2026-11-12); AD FS's "An error
|
|
582
|
+
# occurred. Contact your administrator" (two schools' AD FS, 2026-11-13).
|
|
582
583
|
_IDP_ERROR_RE = re.compile(r"未知错误|系统错误|服务异常|认证失败|出错了|\b5\d{4}\b.{0,20}错误|an unexpected error|error code|system error"
|
|
583
|
-
r"|message security error", re.I)
|
|
584
|
+
r"|message security error|an error occurred\. contact your administrator", re.I)
|
|
584
585
|
|
|
585
586
|
# A publisher's own terms form on the way to the school: SIAM's SAML consent
|
|
586
587
|
# ("I have read and agree to the Terms and Conditions and Privacy Policy.",
|
|
@@ -734,6 +735,7 @@ class LoginMixin:
|
|
|
734
735
|
r"|application you have accessed is not registered|may not be enabled for this type of authentication"
|
|
735
736
|
r"|can't find your institution|access to this resource has been restricted by your organization|oa-ap-4032"
|
|
736
737
|
r"|不支持的请求|does not have access to this resource|message security error|reported an idp error"
|
|
738
|
+
r"|an error occurred\. contact your administrator|application not authorized to use cas"
|
|
737
739
|
r"|temporarily unavailable|verify you are human|are you a robot|checking your browser|正在进行安全验证", re.I)
|
|
738
740
|
|
|
739
741
|
def _login_block_reason(self, page: Any) -> str:
|
|
@@ -832,6 +834,10 @@ class LoginMixin:
|
|
|
832
834
|
return "institution_pdf_entitlement_missing"
|
|
833
835
|
if "application you have accessed is not registered" in haystack:
|
|
834
836
|
return "institution_not_registered"
|
|
837
|
+
# Apereo CAS as the school's identity provider, the publisher not enabled there
|
|
838
|
+
# ("Application Not Authorized to Use CAS", 2026-11-13).
|
|
839
|
+
if "application not authorized to use cas" in haystack and self._is_idp_host(urlparse(current_url).netloc):
|
|
840
|
+
return "institution_not_registered"
|
|
835
841
|
if "your institution may not be enabled for this type of authentication" in haystack:
|
|
836
842
|
return "institution_not_registered"
|
|
837
843
|
if "can't find your institution" in haystack and "institution sign in" in haystack:
|
|
@@ -1480,11 +1486,18 @@ class LoginMixin:
|
|
|
1480
1486
|
url = str(getattr(page, "url", "") or "")
|
|
1481
1487
|
return self._school_password_box(page, url) or self._idp_user_action(page)
|
|
1482
1488
|
|
|
1489
|
+
_CREDENTIAL_BOX = 'input[type="password"]:visible, input[autocomplete="one-time-code"]:visible'
|
|
1490
|
+
|
|
1483
1491
|
def _school_password_box(self, page: Any, url: str) -> bool:
|
|
1484
|
-
"""A password or one-time-code field that is not a personal account's box on the
|
|
1492
|
+
"""A password or one-time-code field that is not a personal account's box on the
|
|
1493
|
+
publisher's site; on the school's side also one in a frame of its page (a
|
|
1494
|
+
school's login form shown in a frame, its page's own copy hidden: 2026-11-13)."""
|
|
1485
1495
|
try:
|
|
1486
|
-
|
|
1487
|
-
|
|
1496
|
+
if page.locator(self._CREDENTIAL_BOX).count() and not self._personal_login_box(page, url):
|
|
1497
|
+
return True
|
|
1498
|
+
frames = page.frames if isinstance(getattr(page, "frames", None), list) else []
|
|
1499
|
+
return (len(frames) > 1 and self._is_idp_host(urlparse(url).netloc)
|
|
1500
|
+
and any(frame.locator(self._CREDENTIAL_BOX).count() for frame in frames[1:]))
|
|
1488
1501
|
except Exception as exc:
|
|
1489
1502
|
if not _is_navigation_cut(exc):
|
|
1490
1503
|
raise
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"code": "azsciencenet",
|
|
3
|
+
"name": "AzScienceNet",
|
|
4
|
+
"country": "AZ",
|
|
5
|
+
"registration_authorities": ["https://edugain.azsciencenet.az"],
|
|
6
|
+
"chooser_labels": ["AzScienceNet Identity Federation"],
|
|
7
|
+
"chooser_pattern": "\\bAzScienceNet\\b",
|
|
8
|
+
"discovery_hosts": [],
|
|
9
|
+
"service_domains": ["edugain.azsciencenet.az"],
|
|
10
|
+
"metadata_url": "https://registry1.azsciencenet.az/rr3/signedmetadata/federation/AzScienceNetIF/metadata.xml"
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"code": "belnet",
|
|
3
|
+
"name": "Belnet",
|
|
4
|
+
"country": "BE",
|
|
5
|
+
"registration_authorities": ["http://federation.belnet.be/"],
|
|
6
|
+
"chooser_labels": ["Belnet Federation"],
|
|
7
|
+
"chooser_pattern": "\\bBelnet\\b",
|
|
8
|
+
"discovery_hosts": [],
|
|
9
|
+
"service_domains": ["federation.belnet.be"],
|
|
10
|
+
"metadata_url": "https://federation.belnet.be/metadata/edugain-metadata.xml"
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"code": "cstcloud",
|
|
3
|
+
"name": "CSTCloud",
|
|
4
|
+
"country": "CN",
|
|
5
|
+
"registration_authorities": ["https://www.cstcloud.net/"],
|
|
6
|
+
"chooser_labels": ["CSTCloud Federation"],
|
|
7
|
+
"chooser_pattern": "\\bCSTCloud\\b|中国科技云",
|
|
8
|
+
"discovery_hosts": [],
|
|
9
|
+
"service_domains": ["cstcloud.net"],
|
|
10
|
+
"metadata_url": "http://www.cstcloud.net/discovery/metadata/cstcloud-fed-metadata-sig.xml"
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"code": "cynet",
|
|
3
|
+
"name": "CyNet",
|
|
4
|
+
"country": "CY",
|
|
5
|
+
"registration_authorities": ["https://cif.cynet.ac.cy"],
|
|
6
|
+
"chooser_labels": ["CyNet Identity Federation"],
|
|
7
|
+
"chooser_pattern": "\\bCyNet\\b",
|
|
8
|
+
"discovery_hosts": [],
|
|
9
|
+
"service_domains": ["cif.cynet.ac.cy"],
|
|
10
|
+
"metadata_url": "https://cif.cynet.ac.cy/md/edugain-upstream.xml"
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"code": "edugate",
|
|
3
|
+
"name": "Edugate",
|
|
4
|
+
"country": "IE",
|
|
5
|
+
"registration_authorities": ["http://www.heanet.ie"],
|
|
6
|
+
"chooser_labels": ["Ireland - Edugate Federation"],
|
|
7
|
+
"chooser_pattern": "\\bEdugate\\b",
|
|
8
|
+
"discovery_hosts": [],
|
|
9
|
+
"service_domains": ["edugate.heanet.ie"],
|
|
10
|
+
"metadata_url": "https://edugate.heanet.ie/rr3/signedmetadata/federationexport/ZWR1R0FJTg~~/metadata.xml"
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"code": "eduidlu",
|
|
3
|
+
"name": "eduID Luxembourg",
|
|
4
|
+
"country": "LU",
|
|
5
|
+
"registration_authorities": ["http://eduid.lu"],
|
|
6
|
+
"chooser_labels": ["eduID Luxembourg"],
|
|
7
|
+
"chooser_pattern": "\\beduID\\s+Luxembourg\\b",
|
|
8
|
+
"discovery_hosts": [],
|
|
9
|
+
"service_domains": ["eduid.lu"],
|
|
10
|
+
"metadata_url": "https://www.eduid.lu/metadata/upstream.xml"
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"code": "irfed",
|
|
3
|
+
"name": "IRFED",
|
|
4
|
+
"country": "IR",
|
|
5
|
+
"registration_authorities": ["https://irfed.ir/"],
|
|
6
|
+
"chooser_labels": ["IRFED"],
|
|
7
|
+
"chooser_pattern": "\\bIRFED\\b",
|
|
8
|
+
"discovery_hosts": [],
|
|
9
|
+
"service_domains": ["irfed.ir"],
|
|
10
|
+
"metadata_url": "https://irfed.ir/IRFED.xml"
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"code": "iucc",
|
|
3
|
+
"name": "IUCC",
|
|
4
|
+
"country": "IL",
|
|
5
|
+
"registration_authorities": ["http://iif.iucc.ac.il"],
|
|
6
|
+
"chooser_labels": ["IUCC Identity Federation"],
|
|
7
|
+
"chooser_pattern": "\\bIUCC\\b",
|
|
8
|
+
"discovery_hosts": [],
|
|
9
|
+
"service_domains": ["iif.iucc.ac.il"],
|
|
10
|
+
"metadata_url": "https://iif-ng.iucc.ac.il/md/iif-ng.xml"
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"code": "maeen",
|
|
3
|
+
"name": "Maeen",
|
|
4
|
+
"country": "SA",
|
|
5
|
+
"registration_authorities": ["https://www.maeen.sa"],
|
|
6
|
+
"chooser_labels": ["Maeen Identity Federation"],
|
|
7
|
+
"chooser_pattern": "\\bMaeen\\b",
|
|
8
|
+
"discovery_hosts": [],
|
|
9
|
+
"service_domains": ["maeen.sa"],
|
|
10
|
+
"metadata_url": "https://md.maeen.sa/metadata/maeen-edugain-metadata.xml"
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"code": "renater",
|
|
3
|
+
"name": "RENATER",
|
|
4
|
+
"country": "FR",
|
|
5
|
+
"registration_authorities": ["https://federation.renater.fr/"],
|
|
6
|
+
"chooser_labels": ["Fédération Éducation-Recherche (Renater)"],
|
|
7
|
+
"chooser_pattern": "\\bRENATER\\b|\\bF[ée]d[ée]ration\\s+[ÉE]ducation[- ]Recherche\\b",
|
|
8
|
+
"discovery_hosts": [],
|
|
9
|
+
"service_domains": ["federation.renater.fr"],
|
|
10
|
+
"metadata_url": "https://pub.federation.renater.fr/metadata/edugain-upstream/renater-edugain-upstream-metadata.xml"
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"code": "surfconext",
|
|
3
|
+
"name": "SURFconext",
|
|
4
|
+
"country": "NL",
|
|
5
|
+
"registration_authorities": ["http://www.surfconext.nl/"],
|
|
6
|
+
"chooser_labels": ["SURFconext"],
|
|
7
|
+
"chooser_pattern": "\\bSURFconext\\b",
|
|
8
|
+
"discovery_hosts": [],
|
|
9
|
+
"service_domains": ["surfconext.nl"],
|
|
10
|
+
"metadata_url": "https://metadata.surfconext.nl/signed/2023/edugain-upstream.xml"
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"code": "ukfederation",
|
|
3
|
+
"name": "UK federation",
|
|
4
|
+
"country": "GB",
|
|
5
|
+
"registration_authorities": ["http://ukfederation.org.uk"],
|
|
6
|
+
"chooser_labels": ["UK Higher Education", "UK Access Management Federation", "UK federation (United Kingdom)"],
|
|
7
|
+
"chooser_pattern": "\\bUK\\s+(?:Access\\s+Management\\s+)?Federation\\b|\\bUK\\s+Higher\\s+Education\\b",
|
|
8
|
+
"discovery_hosts": [],
|
|
9
|
+
"service_domains": ["ukfederation.org.uk"],
|
|
10
|
+
"metadata_url": "http://metadata.ukfederation.org.uk/ukfederation-export.xml"
|
|
11
|
+
}
|
|
@@ -21,8 +21,9 @@ from __future__ import annotations
|
|
|
21
21
|
import hashlib
|
|
22
22
|
import re
|
|
23
23
|
import time
|
|
24
|
+
import unicodedata
|
|
24
25
|
import xml.etree.ElementTree as ET
|
|
25
|
-
from dataclasses import dataclass, field
|
|
26
|
+
from dataclasses import dataclass, field, replace
|
|
26
27
|
from pathlib import Path
|
|
27
28
|
from typing import Any, Iterable
|
|
28
29
|
from urllib.parse import quote, urlparse
|
|
@@ -154,10 +155,16 @@ def institutional_configured(config: dict[str, Any]) -> bool:
|
|
|
154
155
|
|
|
155
156
|
# --------------------------------------------------------------------------- finding
|
|
156
157
|
|
|
158
|
+
def _plain(text: str) -> str:
|
|
159
|
+
"""Accents on Latin and Greek letters do not count ("Universite" listed for
|
|
160
|
+
"Université", 2026-11-13); other scripts' marks (Japanese voicing) stay."""
|
|
161
|
+
return unicodedata.normalize("NFC", re.sub(r"[\u0300-\u036f]", "", unicodedata.normalize("NFD", str(text or ""))))
|
|
162
|
+
|
|
163
|
+
|
|
157
164
|
def _key(text: str) -> str:
|
|
158
|
-
"""Case, spaces, hyphens, punctuation and a leading "The" do not
|
|
159
|
-
is "and" (a school listed as "Science & Technology", 2026-11-12)."""
|
|
160
|
-
text = re.sub(r"^the\s+", "",
|
|
165
|
+
"""Case, spaces, hyphens, punctuation, accents and a leading "The" do not
|
|
166
|
+
count; "&" is "and" (a school listed as "Science & Technology", 2026-11-12)."""
|
|
167
|
+
text = re.sub(r"^the\s+", "", _plain(text).casefold().strip())
|
|
161
168
|
return re.sub(r"[\W_]+", "", text.replace("&", " and "))
|
|
162
169
|
|
|
163
170
|
|
|
@@ -175,8 +182,12 @@ class _Found:
|
|
|
175
182
|
|
|
176
183
|
def __init__(self) -> None:
|
|
177
184
|
self.rows: dict[str, tuple[School, bool]] = {}
|
|
185
|
+
# The entries found by one of their names, not only by a domain or entityID.
|
|
186
|
+
self.named: set[str] = set()
|
|
178
187
|
|
|
179
|
-
def add(self, school: School, exact: bool) -> None:
|
|
188
|
+
def add(self, school: School, exact: bool, named: bool = True) -> None:
|
|
189
|
+
if named:
|
|
190
|
+
self.named.add(school.entity_id)
|
|
180
191
|
known = self.rows.get(school.entity_id)
|
|
181
192
|
if known is None or (exact and not known[1]):
|
|
182
193
|
self.rows[school.entity_id] = (school, exact)
|
|
@@ -195,6 +206,8 @@ class _Found:
|
|
|
195
206
|
matches a campus in CARSI, the school itself is listed in English)."""
|
|
196
207
|
self._primary()
|
|
197
208
|
exact = [s for s, e in self.rows.values() if e]
|
|
209
|
+
if len(exact) > 1:
|
|
210
|
+
exact = [_one_school(exact)] if _one_school(exact) else exact
|
|
198
211
|
if len(exact) == 1:
|
|
199
212
|
return exact[0], []
|
|
200
213
|
if exact:
|
|
@@ -217,6 +230,17 @@ def _same_school(other: School, school: School) -> bool:
|
|
|
217
230
|
return bool({d.rsplit(".", 1)[-1] for d in other.scopes} & {d.rsplit(".", 1)[-1] for d in school.scopes})
|
|
218
231
|
|
|
219
232
|
|
|
233
|
+
def _one_school(schools: list[School]) -> School | None:
|
|
234
|
+
"""One school listed several times in one federation under a domain of its own
|
|
235
|
+
(a second login server, an alumni-only one: 2026-11-13): its entry with the
|
|
236
|
+
plainest name, the one the others' names contain. A shared entry (a national
|
|
237
|
+
one covering the school's domain) has another name and keeps them apart."""
|
|
238
|
+
if len({s.federation for s in schools}) != 1 or not set.intersection(*(set(s.scopes) for s in schools)):
|
|
239
|
+
return None
|
|
240
|
+
plain = min(schools, key=lambda s: (len(s.name), s.name))
|
|
241
|
+
return plain if all(_key(plain.name) in _key(s.name) for s in schools) else None
|
|
242
|
+
|
|
243
|
+
|
|
220
244
|
def _secondary(school: School) -> bool:
|
|
221
245
|
federation = by_code(school.federation)
|
|
222
246
|
return bool(federation and federation.secondary)
|
|
@@ -229,6 +253,9 @@ _RETIRED = re.compile(r"\bdo not use\b|\btest\b|\blegacy\b", re.I)
|
|
|
229
253
|
_PARTS = re.compile(r"\s+[-\u2013\u2014]\s+")
|
|
230
254
|
_BRACKET = re.compile(r"\(([^()]+)\)")
|
|
231
255
|
# Chinese, Japanese and Korean writing, beside a name in Latin letters.
|
|
256
|
+
# A word naming the login server, not the school, at the end of a listed name
|
|
257
|
+
# ("<School> IdP", 2026-11-13).
|
|
258
|
+
_SERVER_WORD = re.compile(r"\s+(?:IdP|Identity\s+Provider|SSO)$", re.I)
|
|
232
259
|
_CJK = re.compile(r"[\u3040-\u30ff\u3400-\u9fff\uac00-\ud7af][\u3040-\u30ff\u3400-\u9fff\uac00-\ud7af\s・·]*")
|
|
233
260
|
|
|
234
261
|
|
|
@@ -237,14 +264,15 @@ def _names(titles: Iterable[str]) -> list[str]:
|
|
|
237
264
|
Harbour University" (an abbreviation before the name), "北大学 (Kita
|
|
238
265
|
University) – OpenAthens" (a second name in brackets, the route after a dash),
|
|
239
266
|
"National Harbour Bay University (NHBU) 海灣大學" (brackets inside, and a name in
|
|
240
|
-
another script beside the English one: OpenAthens in Taiwan, 2026-11-12)
|
|
267
|
+
another script beside the English one: OpenAthens in Taiwan, 2026-11-12),
|
|
268
|
+
"Harbour University IdP" (the login server's word after the name)."""
|
|
241
269
|
names = [str(t).strip() for t in titles if str(t or "").strip()]
|
|
242
270
|
found = list(names)
|
|
243
271
|
for name in names:
|
|
244
272
|
for part in _PARTS.split(name):
|
|
245
273
|
part = part.strip()
|
|
246
274
|
outside = re.sub(r"\s+", " ", _BRACKET.sub(" ", part)).strip()
|
|
247
|
-
found += [part, outside, *(m.strip() for m in _BRACKET.findall(part))]
|
|
275
|
+
found += [part, outside, _SERVER_WORD.sub("", outside), *(m.strip() for m in _BRACKET.findall(part))]
|
|
248
276
|
if _CJK.search(outside) and re.search(r"[A-Za-z]{2}", _CJK.sub(" ", outside)):
|
|
249
277
|
found += [m.strip() for m in _CJK.findall(outside)] + [re.sub(r"\s+", " ", _CJK.sub(" ", outside)).strip()]
|
|
250
278
|
return list(dict.fromkeys(n for n in found if n))
|
|
@@ -252,7 +280,7 @@ def _names(titles: Iterable[str]) -> list[str]:
|
|
|
252
280
|
|
|
253
281
|
def _words(text: str) -> list[str]:
|
|
254
282
|
"""The words of a name, as ``_key`` compares them."""
|
|
255
|
-
words = [w for w in re.split(r"[\W_]+",
|
|
283
|
+
words = [w for w in re.split(r"[\W_]+", _plain(text).casefold().replace("&", " and ")) if w]
|
|
256
284
|
return words[1:] if words[:1] == ["the"] else words
|
|
257
285
|
|
|
258
286
|
|
|
@@ -315,7 +343,9 @@ def _seamlessaccess(text: str, config: dict[str, Any]) -> list[dict[str, Any]]:
|
|
|
315
343
|
|
|
316
344
|
def _from_seamlessaccess(given: list[str], config: dict[str, Any], found: _Found, lookup: Lookup,
|
|
317
345
|
carsi_listed: bool) -> None:
|
|
318
|
-
|
|
346
|
+
# Its search keeps accents: a name given with them is also searched without
|
|
347
|
+
# ("Université" listed as "Universite", 2026-11-13).
|
|
348
|
+
for text in dict.fromkeys([*given, *(_plain(t) for t in given)]):
|
|
319
349
|
try:
|
|
320
350
|
rows = _seamlessaccess(text, config)
|
|
321
351
|
except Exception:
|
|
@@ -341,9 +371,13 @@ def _from_seamlessaccess(given: list[str], config: dict[str, Any], found: _Found
|
|
|
341
371
|
continue
|
|
342
372
|
if federation.member_list == "carsi" and carsi_listed:
|
|
343
373
|
continue # CARSI's own list is the source for its schools
|
|
344
|
-
english = str((row.get("title_langs") or {}).get("en") or title)
|
|
345
|
-
|
|
346
|
-
|
|
374
|
+
english = _SERVER_WORD.sub("", str((row.get("title_langs") or {}).get("en") or title)).strip()
|
|
375
|
+
# The name in the school's own language when that is the one given: publishers
|
|
376
|
+
# may list it so (a French name searched in English found nothing, 2026-11-13).
|
|
377
|
+
local = next((str(v) for k, v in (row.get("title_langs") or {}).items()
|
|
378
|
+
if k != "en" and any(_key(t) == _key(v) for t in given)), english)
|
|
379
|
+
found.add(School(local, english, entity, federation.code, scopes[0] if scopes else "",
|
|
380
|
+
scopes=tuple(scopes)), exact, named=_named(given, titles))
|
|
347
381
|
|
|
348
382
|
|
|
349
383
|
def _metadata(federation: Federation, config: dict[str, Any], data_dir: Path) -> ET.Element:
|
|
@@ -373,7 +407,7 @@ def _metadata_schools(federation: Federation, root: ET.Element) -> list[tuple[Sc
|
|
|
373
407
|
for n in idp.findall("md:Extensions/mdui:UIInfo/mdui:DisplayName", _NS)}
|
|
374
408
|
organization = [(n.text or "").strip() for n in entity.findall("md:Organization/md:OrganizationDisplayName", _NS)]
|
|
375
409
|
listed = _names([*display.values(), *organization])
|
|
376
|
-
english = display.get("en") or (organization[0] if organization else entity_id)
|
|
410
|
+
english = _SERVER_WORD.sub("", display.get("en") or (organization[0] if organization else entity_id)).strip()
|
|
377
411
|
if _RETIRED.search(english):
|
|
378
412
|
continue
|
|
379
413
|
scopes = [(s.text or "").strip().lower() for s in idp.findall("md:Extensions/shibmd:Scope", _NS)]
|
|
@@ -398,7 +432,7 @@ def _from_metadata(given: list[str], config: dict[str, Any], data_dir: Path, fou
|
|
|
398
432
|
for school, listed, scopes in _metadata_schools(federation, root):
|
|
399
433
|
exact, partial = _matches(given, listed, scopes, school.entity_id)
|
|
400
434
|
if exact or partial:
|
|
401
|
-
found.add(school, exact)
|
|
435
|
+
found.add(school, exact, named=_named(given, listed))
|
|
402
436
|
|
|
403
437
|
|
|
404
438
|
def _with_login_hosts(school: School, config: dict[str, Any], data_dir: Path) -> School:
|
|
@@ -417,6 +451,24 @@ def _with_login_hosts(school: School, config: dict[str, Any], data_dir: Path) ->
|
|
|
417
451
|
school.domain or listed.domain, listed.login_hosts, school.scopes)
|
|
418
452
|
|
|
419
453
|
|
|
454
|
+
def _named(given: Iterable[str], listed_names: Iterable[str]) -> bool:
|
|
455
|
+
"""One of the names given is one the entry is listed under."""
|
|
456
|
+
keys = {_key(n) for n in listed_names} - {""}
|
|
457
|
+
return any(_key(t) in keys for t in given)
|
|
458
|
+
|
|
459
|
+
|
|
460
|
+
def _named_as_given(school: School, given: list[str]) -> School:
|
|
461
|
+
"""A school found only by its domain, under a login entry many schools share
|
|
462
|
+
(a school system's ID, a national entry: 2026-11-13), is named as the user named it: that
|
|
463
|
+
name is what publishers' choosers list it under; the user's English name
|
|
464
|
+
second when given, else the entry's."""
|
|
465
|
+
own = [t for t in given if not _is_entity_id(t) and not re.fullmatch(r"[\w-]+(?:\.[\w-]+)+", t)]
|
|
466
|
+
if not own:
|
|
467
|
+
return school
|
|
468
|
+
english = next((t for t in own if t.isascii()), school.name_en)
|
|
469
|
+
return replace(school, name=own[0], name_en=english)
|
|
470
|
+
|
|
471
|
+
|
|
420
472
|
def find(query: str, config: dict[str, Any], data_dir: Path, *, also: Iterable[str] = ()) -> Lookup:
|
|
421
473
|
"""The school named ``query`` (any language, its domain or entityID), with
|
|
422
474
|
``also`` its other names (the English one, given by the caller)."""
|
|
@@ -429,6 +481,8 @@ def find(query: str, config: dict[str, Any], data_dir: Path, *, also: Iterable[s
|
|
|
429
481
|
if "SeamlessAccess" in lookup.unavailable:
|
|
430
482
|
_from_metadata(given, config, data_dir, found, lookup)
|
|
431
483
|
school, candidates = found.decide()
|
|
484
|
+
if school is not None and school.entity_id not in found.named:
|
|
485
|
+
school = _named_as_given(school, given)
|
|
432
486
|
lookup.school = _with_login_hosts(school, config, data_dir) if school else None
|
|
433
487
|
lookup.candidates = candidates[:10]
|
|
434
488
|
return lookup
|
|
@@ -4,7 +4,7 @@ description: |
|
|
|
4
4
|
用本机 paper-search 命令做文献工作:检索论文、核对 DOI/PMID、搜正文片段(找方法和结果的原文)、查期刊影响因子与分区、查施引和参考文献、下载全文和补充材料。
|
|
5
5
|
用户要找文献、查期刊、下载论文,或说“请开始配置”时使用;英文请求(literature search、journal metrics、paper download、start setup)同样适用。
|
|
6
6
|
metadata:
|
|
7
|
-
version: "0.6.
|
|
7
|
+
version: "0.6.4"
|
|
8
8
|
---
|
|
9
9
|
|
|
10
10
|
# 文献检索与下载(paper-search)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# 学校订阅下载:各学术身份联盟支持情况
|
|
2
2
|
|
|
3
|
-
本表说明学校订阅下载能经哪些学术身份联盟登录(截至 2026-11-
|
|
3
|
+
本表说明学校订阅下载能经哪些学术身份联盟登录(截至 2026-11-13)。“支持”是说:用户说出学校名称,程序能查出学校所属的联盟,并在出版社网站上自动选好联盟和学校,走到学校的登录页。登录之后能否下到全文,取决于学校的订阅,以及出版社是否给这所学校开通了学校账号登录。
|
|
4
4
|
|
|
5
5
|
各国的学术身份联盟通过 eduGAIN 互联,出版社借此认可各国学校的账号;OpenAthens 是跨国的机构登录服务,没有加入本国联盟的学校不少经它登录。
|
|
6
6
|
|
|
@@ -11,37 +11,110 @@
|
|
|
11
11
|
|
|
12
12
|
符号:✓ 已实测(自动走到学校登录页);○ 已支持,尚未实测。
|
|
13
13
|
|
|
14
|
+
按大洲和区域列出,顺序与扩展计划相同:亚洲(东亚、东南亚、南亚、中亚、西亚)→ 欧洲(西欧、北欧、中欧、南欧、东欧)→ 美洲(北美洲:美国、加拿大;拉丁美洲和加勒比:中美洲、加勒比、南美洲)→ 大洋洲(澳大利亚与新西兰、美拉尼西亚、密克罗尼西亚、波利尼西亚)→ 非洲。
|
|
15
|
+
|
|
14
16
|
## 亚洲
|
|
15
17
|
|
|
18
|
+
### 东亚
|
|
19
|
+
|
|
16
20
|
| 地区 | 联盟 | 全称 | 联盟内学校数 | 状态 | 已实测的学校 |
|
|
17
21
|
| --- | --- | --- | --- | --- | --- |
|
|
18
22
|
| 中国内地、澳门 | CARSI | CERNET 联邦认证与资源共享基础设施(CERNET Authentication and Resource Sharing Infrastructure) | 约 590 | ✓ | 澳门大学、澳门科技大学 |
|
|
19
23
|
| 香港 | HKAF | Hong Kong Access Federation | 15 | ✓ | 香港大学、香港中文大学、香港科技大学、香港理工大学 |
|
|
20
|
-
| 新加坡 | SGAF | Singapore Access Federation | 13 | ✓ | 新加坡国立大学、南洋理工大学、新加坡管理大学 |
|
|
21
24
|
| 日本 | GakuNin(学認) | 学術認証フェデレーション(Academic Access Management Federation in Japan) | 约 170 | ✓ | 东京大学、大阪大学、东北大学、庆应义塾大学、早稻田大学 |
|
|
22
25
|
| 韩国 | KAFE | Korean Access Federation | 27 | ✓ | KAIST、延世大学、浦项工科大学、成均馆大学 |
|
|
26
|
+
| 中国内地(科研机构) | CSTCloud | 中国科技云联盟(CSTCloud Federation) | 10 | ✓ | 中国科学院上海应用物理研究所(经中国科技云通行证)、北京协和医学院(经协和统一身份认证) |
|
|
27
|
+
|
|
28
|
+
- 中国科技云联盟供中国内地的科研院所等机构使用;同时在 CARSI 里的学校按 CARSI 登录。经共用入口登录的科研院所,配置时同时给出机构名称和官网域名。
|
|
29
|
+
- 台湾没有加入 eduGAIN 的联盟,台湾的学校经 OpenAthens 登录;没有接入 OpenAthens 的台湾学校暂时无法使用。
|
|
30
|
+
|
|
31
|
+
### 东南亚
|
|
32
|
+
|
|
33
|
+
| 地区 | 联盟 | 全称 | 联盟内学校数 | 状态 | 已实测的学校 |
|
|
34
|
+
| --- | --- | --- | --- | --- | --- |
|
|
35
|
+
| 新加坡 | SGAF | Singapore Access Federation | 13 | ✓ | 新加坡国立大学、南洋理工大学、新加坡管理大学 |
|
|
23
36
|
| 马来西亚 | SIFULAN | SIFULAN Malaysian Access Federation | 约 150 | ✓ | 马来西亚理科大学、博特拉大学 |
|
|
37
|
+
|
|
38
|
+
- 泰国、菲律宾等地的学校多经 OpenAthens 登录(见“跨地区”);泰国的联盟 ThaiIDF 只有两个全国入口,且交给 eduGAIN 的名单目前已过期,暂不支持。
|
|
39
|
+
|
|
40
|
+
### 南亚
|
|
41
|
+
|
|
42
|
+
| 地区 | 联盟 | 全称 | 联盟内学校数 | 状态 | 已实测的学校 |
|
|
43
|
+
| --- | --- | --- | --- | --- | --- |
|
|
24
44
|
| 印度 | INFED | INFLIBNET Access Management Federation | 约 390 | ✓ | 印度理工学院德里分校 |
|
|
25
|
-
| 土耳其 | YETKİM | YETKİM Identity Federation | 约 170 | ✓ | 哈杰泰佩大学、中东技术大学、海峡大学、伊斯坦布尔大学 |
|
|
26
45
|
| 斯里兰卡 | LIAF | LEARN Identity Access Federation | 31 | ✓ | 科伦坡大学 |
|
|
27
46
|
| 孟加拉 | TIGERfed | Trust, Identity and Group management for Education and Research Federation | 30 | ✓ | 孟加拉工程技术大学 |
|
|
28
47
|
| 巴基斯坦 | PKIFED | Pakistan Identity Federation | 8 | ✓ | COMSATS 大学伊斯兰堡分校、巴基斯坦国立科技大学、真纳大学 |
|
|
48
|
+
|
|
49
|
+
- 巴基斯坦有一百多所学校经 PERN 全国共用入口登录,联盟名单里只有它们的域名:按校名查不到时,同时给出校名和学校官网域名配置。
|
|
50
|
+
|
|
51
|
+
### 中亚
|
|
52
|
+
|
|
53
|
+
暂无可用的联盟:吉尔吉斯斯坦的 KRENA 只有联盟自己的一个账号入口,没有学校入口;塔吉克斯坦的联盟尚未正式运行;哈萨克斯坦、乌兹别克斯坦没有联盟。
|
|
54
|
+
|
|
55
|
+
### 西亚
|
|
56
|
+
|
|
57
|
+
| 地区 | 联盟 | 全称 | 联盟内学校数 | 状态 | 已实测的学校 |
|
|
58
|
+
| --- | --- | --- | --- | --- | --- |
|
|
59
|
+
| 土耳其 | YETKİM | YETKİM Identity Federation | 约 170 | ✓ | 哈杰泰佩大学、中东技术大学、海峡大学、伊斯坦布尔大学 |
|
|
60
|
+
| 沙特阿拉伯 | Maeen | Maeen Identity Federation | 36 | ○ | — |
|
|
61
|
+
| 塞浦路斯 | CyNet | CyNet Identity Federation | 10 | ✓ | 塞浦路斯大学、塞浦路斯技术大学 |
|
|
62
|
+
| 以色列 | IUCC | IUCC Identity Federation | 1 个共用入口 | ✓ | 特拉维夫大学、希伯来大学 |
|
|
63
|
+
| 伊朗 | IRFED | IRFED | 2 | ○ | — |
|
|
64
|
+
| 阿塞拜疆 | AzScienceNet | AzScienceNet Identity Federation | 2 | ○ | — |
|
|
29
65
|
| 阿曼 | OMREN | OMREN Identity Federation | 约 30 | ○ | — |
|
|
30
|
-
| 跨地区 | OpenAthens | OpenAthens 机构登录服务 | — | ✓ | 马来亚大学、朱拉隆功大学、菲律宾大学 Diliman、名古屋大学、台湾大学、阳明交通大学、台湾师范大学 |
|
|
31
66
|
|
|
32
|
-
-
|
|
33
|
-
-
|
|
34
|
-
-
|
|
35
|
-
- 巴基斯坦有一百多所学校经 PERN 全国共用入口登录,联盟名单里只有它们的域名:按校名查不到时,用学校官网域名配置。
|
|
67
|
+
- 以色列的大学经 IUCC 共用入口登录,联盟名单里只有它们的域名:配置时同时给出校名和学校官网域名。
|
|
68
|
+
- 沙特的大学在出版社上能自动选中,但从境外测试时,有的学校登录服务器连不上,有的学校未为出版社开通,尚未走到能输入账号的登录页。
|
|
69
|
+
- 伊朗、阿塞拜疆的联盟各只有一所学校;出版社不一定为这些学校开通联盟登录,程序会写明原因。
|
|
36
70
|
- 阿曼 OMREN 交给 eduGAIN 的学校名单目前已过期,阿曼的学校暂时查不到;名单恢复后无需改动即可使用。
|
|
37
|
-
-
|
|
71
|
+
- 亚美尼亚、格鲁吉亚的联盟只登记了网络运营方、研究所和图书馆的入口,没有学校入口;黎巴嫩的联盟尚未正式运行。
|
|
72
|
+
|
|
73
|
+
## 欧洲
|
|
74
|
+
|
|
75
|
+
### 西欧
|
|
76
|
+
|
|
77
|
+
| 地区 | 联盟 | 全称 | 联盟内学校数 | 状态 | 已实测的学校 |
|
|
78
|
+
| --- | --- | --- | --- | --- | --- |
|
|
79
|
+
| 英国 | UK federation | UK Access Management Federation | 约 690 | ✓ | 牛津大学、剑桥大学、帝国理工学院、伦敦大学学院、伦敦国王学院、爱丁堡大学、伦敦政治经济学院 |
|
|
80
|
+
| 爱尔兰 | Edugate | Edugate | 41 | ✓ | 都柏林圣三一学院、都柏林大学 |
|
|
81
|
+
| 法国 | RENATER | Fédération Éducation-Recherche | 约 310 | ✓ | 巴黎西岱大学、巴黎-萨克雷大学、斯特拉斯堡大学 |
|
|
82
|
+
| 荷兰 | SURFconext | SURFconext | 约 200 | ✓ | 阿姆斯特丹大学、莱顿大学、乌得勒支大学、代尔夫特理工大学 |
|
|
83
|
+
| 比利时 | Belnet | Belnet Federation | 58 | ✓ | 根特大学、鲁汶天主教大学、布鲁塞尔自由大学 |
|
|
84
|
+
| 卢森堡 | eduID Luxembourg | eduID Luxembourg | 12 | ✓ | 卢森堡大学 |
|
|
85
|
+
|
|
86
|
+
- 荷兰的学校都经 SURFconext 的统一中转站登录,程序自动经过。
|
|
87
|
+
- 法国、荷兰、比利时的学校可以用当地语言的校名配置;出版社按一个名称搜不到时,程序会换学校的其他名称再搜。
|
|
88
|
+
|
|
89
|
+
计划中:北欧、中欧、南欧、东欧。
|
|
38
90
|
|
|
39
91
|
## 美洲
|
|
40
92
|
|
|
93
|
+
### 北美洲
|
|
94
|
+
|
|
41
95
|
| 地区 | 联盟 | 全称 | 联盟内学校数 | 状态 | 已实测的学校 |
|
|
42
96
|
| --- | --- | --- | --- | --- | --- |
|
|
43
97
|
| 美国 | InCommon | InCommon Federation | 约 590 | ✓ | 斯坦福大学、麻省理工学院、耶鲁大学、普林斯顿大学、哥伦比亚大学、加州大学伯克利分校、加州大学洛杉矶分校、加州大学旧金山分校、密歇根大学、宾夕法尼亚大学、杜克大学、华盛顿大学、纽约大学、康奈尔大学、约翰斯·霍普金斯大学 |
|
|
44
98
|
|
|
45
|
-
|
|
99
|
+
计划中:加拿大,再拉丁美洲和加勒比(中美洲、加勒比、南美洲)。
|
|
100
|
+
|
|
101
|
+
## 大洋洲
|
|
102
|
+
|
|
103
|
+
计划中:澳大利亚与新西兰、美拉尼西亚、密克罗尼西亚、波利尼西亚。
|
|
46
104
|
|
|
47
|
-
|
|
105
|
+
## 非洲
|
|
106
|
+
|
|
107
|
+
计划中。
|
|
108
|
+
|
|
109
|
+
## 跨地区
|
|
110
|
+
|
|
111
|
+
| 地区 | 联盟 | 全称 | 联盟内学校数 | 状态 | 已实测的学校 |
|
|
112
|
+
| --- | --- | --- | --- | --- | --- |
|
|
113
|
+
| 跨地区 | OpenAthens | OpenAthens 机构登录服务 | — | ✓ | 马来亚大学、朱拉隆功大学、菲律宾大学 Diliman、名古屋大学、台湾大学、阳明交通大学、台湾师范大学 |
|
|
114
|
+
|
|
115
|
+
- OpenAthens 不是某个国家的联盟,是跨国的机构登录服务;学校同时有本国联盟入口时,程序优先用联盟的。
|
|
116
|
+
|
|
117
|
+
## 说明
|
|
118
|
+
|
|
119
|
+
- 联盟内学校数取自 eduGAIN 登记的身份提供方数量,一所学校可能登记不止一个。
|
|
120
|
+
- 学校登录服务器连不上,或学校认证服务器拒绝出版社的登录请求时,程序立即结束并说明“学校登录系统出错”;这类情况要由学校处理。
|
|
@@ -53,8 +53,9 @@ paper-search school login --doi <学校订阅的一篇文章的 DOI>
|
|
|
53
53
|
paper-search-school setup --institution "用户说的校名" [--also-name "学校的英文正式名称"]
|
|
54
54
|
```
|
|
55
55
|
|
|
56
|
-
- 目前支持中国内地和澳门(CARSI)、香港(HKAF)、新加坡(SGAF)、日本(GakuNin)、韩国(KAFE)、马来西亚(SIFULAN)、印度(INFED)、土耳其(YETKİM)、斯里兰卡(LIAF)、孟加拉(TIGERfed)、巴基斯坦(PKIFED)、阿曼(OMREN)、美国(InCommon)的学术身份联盟,以及只经 OpenAthens 登录的学校。`--institution` 可以是校名(任何语言)、学校域名或 entityID;后端在各联盟的学校名单里查,确定是哪一所才保存,并保存它所属的联盟。
|
|
57
|
-
-
|
|
56
|
+
- 目前支持中国内地和澳门(CARSI)、香港(HKAF)、新加坡(SGAF)、日本(GakuNin)、韩国(KAFE)、马来西亚(SIFULAN)、印度(INFED)、土耳其(YETKİM)、斯里兰卡(LIAF)、孟加拉(TIGERfed)、巴基斯坦(PKIFED)、阿曼(OMREN)、中国内地科研机构(CSTCloud)、沙特阿拉伯(Maeen)、塞浦路斯(CyNet)、以色列(IUCC)、伊朗(IRFED)、阿塞拜疆(AzScienceNet)、英国(UK federation)、爱尔兰(Edugate)、法国(RENATER)、荷兰(SURFconext)、比利时(Belnet)、卢森堡(eduID Luxembourg)、美国(InCommon)的学术身份联盟,以及只经 OpenAthens 登录的学校。`--institution` 可以是校名(任何语言)、学校域名或 entityID;后端在各联盟的学校名单里查,确定是哪一所才保存,并保存它所属的联盟。
|
|
57
|
+
- 联盟名单里的校名是当地语言和英文(中国内地、澳门有中文,日本有日文,土耳其有土耳其文,法国、荷兰、比利时等欧洲国家多有当地语言名,香港、韩国、新加坡、马来西亚、南亚和美国多只有英文)。用户说的校名不是这两种时,加 `--also-name` 给出学校的英文正式名称;不确定英文名就不加。
|
|
58
|
+
- 有些学校经多校共用的登录入口登录(如以色列的大学、中国内地的科研院所、巴基斯坦的部分学校),联盟名单里只有它们的域名:按校名查不到时,用 `--institution <校名> --also-name <学校官网域名>` 再查一次,程序会按域名找到入口,并按所给校名在出版社搜索。
|
|
58
59
|
- 返回 `school_ambiguous` 时,把 `candidates`(含学校名、联盟、域名)列给用户选,再用所选学校的 `entity_id` 作为 `--institution` 重新运行;只有一个候选也要问,那是名字不完全一致的学校。`school_not_found` 时请用户换成学校正式名称、英文名或学校域名,仍找不到就按回复里的 `reasons` 如实说明:这所学校可能没有接入学术身份联盟或 OpenAthens,学校订阅下载无法为它登录;`federation_not_supported` 是找到了学校但它所属的联盟还不支持,如实告诉用户;`school_list_unavailable` 是名单取不到,稍后重试。
|
|
59
60
|
- `--carsi --institution` 只在 CARSI 名单里查(错误码 `carsi_school_*`);查 CARSI 名单:`paper-search-school setup --list-carsi-schools 关键词`。
|
|
60
61
|
- `setup --check` 的 `school` 项为 `missing` 时,说明只存了学校名,按提示重新运行上面的命令。
|