papersearch 0.7.2 → 0.8.0
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/LICENSE-paper-search-mcp-nodejs +24 -0
- package/NOTICE +8 -37
- package/README.en.md +7 -3
- package/README.fr.md +268 -0
- package/README.ja.md +268 -0
- package/README.ko.md +268 -0
- package/README.md +7 -3
- package/README.zh-Hant.md +268 -0
- package/dist/capabilities/download/batch/batch.d.ts +16 -1
- package/dist/capabilities/download/batch/batch.d.ts.map +1 -1
- package/dist/capabilities/download/batch/batch.js +669 -53
- package/dist/capabilities/download/batch/batch.js.map +1 -1
- package/dist/capabilities/download/batch/batchFolder.d.ts.map +1 -1
- package/dist/capabilities/download/batch/batchFolder.js +4 -3
- package/dist/capabilities/download/batch/batchFolder.js.map +1 -1
- package/dist/capabilities/download/batch/batchSummary.js +1 -1
- package/dist/capabilities/download/batch/batchSummary.js.map +1 -1
- package/dist/capabilities/download/batch/networkLoss.d.ts +12 -3
- package/dist/capabilities/download/batch/networkLoss.d.ts.map +1 -1
- package/dist/capabilities/download/batch/networkLoss.js +25 -4
- package/dist/capabilities/download/batch/networkLoss.js.map +1 -1
- package/dist/capabilities/download/batch/resume.d.ts +7 -0
- package/dist/capabilities/download/batch/resume.d.ts.map +1 -1
- package/dist/capabilities/download/batch/resume.js +50 -9
- package/dist/capabilities/download/batch/resume.js.map +1 -1
- package/dist/capabilities/download/content/markdown/pro.d.ts +6 -0
- package/dist/capabilities/download/content/markdown/pro.d.ts.map +1 -1
- package/dist/capabilities/download/content/markdown/pro.js.map +1 -1
- package/dist/capabilities/download/content/markdown/shortfall.d.ts +8 -5
- package/dist/capabilities/download/content/markdown/shortfall.d.ts.map +1 -1
- package/dist/capabilities/download/content/markdown/shortfall.js +27 -15
- package/dist/capabilities/download/content/markdown/shortfall.js.map +1 -1
- package/dist/capabilities/download/content/markdown/step.d.ts +9 -0
- package/dist/capabilities/download/content/markdown/step.d.ts.map +1 -1
- package/dist/capabilities/download/content/markdown/step.js +42 -2
- package/dist/capabilities/download/content/markdown/step.js.map +1 -1
- package/dist/capabilities/download/content/markdown/types.d.ts +10 -1
- package/dist/capabilities/download/content/markdown/types.d.ts.map +1 -1
- package/dist/capabilities/download/handler.d.ts.map +1 -1
- package/dist/capabilities/download/handler.js +13 -5
- package/dist/capabilities/download/handler.js.map +1 -1
- package/dist/capabilities/download/outputLayout.d.ts.map +1 -1
- package/dist/capabilities/download/outputLayout.js +3 -1
- package/dist/capabilities/download/outputLayout.js.map +1 -1
- package/dist/capabilities/download/tools.js +2 -2
- package/dist/capabilities/download/tools.js.map +1 -1
- package/dist/capabilities/download/types.d.ts +9 -1
- package/dist/capabilities/download/types.d.ts.map +1 -1
- package/dist/cli.js +3 -1
- package/dist/cli.js.map +1 -1
- package/dist/infrastructure/runlog/RunLedger.d.ts +7 -0
- package/dist/infrastructure/runlog/RunLedger.d.ts.map +1 -1
- package/dist/infrastructure/runlog/RunLedger.js +13 -0
- package/dist/infrastructure/runlog/RunLedger.js.map +1 -1
- package/dist/infrastructure/runlog/failureClass.d.ts +17 -9
- package/dist/infrastructure/runlog/failureClass.d.ts.map +1 -1
- package/dist/infrastructure/runlog/failureClass.js +89 -56
- package/dist/infrastructure/runlog/failureClass.js.map +1 -1
- package/dist/infrastructure/school/SchoolAttempt.d.ts +11 -0
- package/dist/infrastructure/school/SchoolAttempt.d.ts.map +1 -1
- package/dist/infrastructure/school/SchoolAttempt.js +107 -59
- package/dist/infrastructure/school/SchoolAttempt.js.map +1 -1
- package/dist/infrastructure/school/SchoolMcpClient.d.ts +7 -2
- package/dist/infrastructure/school/SchoolMcpClient.d.ts.map +1 -1
- package/dist/infrastructure/school/SchoolMcpClient.js +30 -7
- package/dist/infrastructure/school/SchoolMcpClient.js.map +1 -1
- package/dist/infrastructure/school/SchoolProgress.d.ts +2 -0
- package/dist/infrastructure/school/SchoolProgress.d.ts.map +1 -1
- package/dist/infrastructure/school/SchoolProgress.js +2 -0
- package/dist/infrastructure/school/SchoolProgress.js.map +1 -1
- package/dist/infrastructure/school/SchoolReadiness.d.ts +2 -0
- package/dist/infrastructure/school/SchoolReadiness.d.ts.map +1 -1
- package/dist/infrastructure/school/SchoolReadiness.js +2 -0
- package/dist/infrastructure/school/SchoolReadiness.js.map +1 -1
- package/dist/infrastructure/school/SchoolResultNormalizer.d.ts.map +1 -1
- package/dist/infrastructure/school/SchoolResultNormalizer.js +4 -0
- package/dist/infrastructure/school/SchoolResultNormalizer.js.map +1 -1
- package/dist/infrastructure/school/index.d.ts +2 -2
- package/dist/infrastructure/school/index.d.ts.map +1 -1
- package/dist/infrastructure/school/index.js +1 -1
- package/dist/infrastructure/school/index.js.map +1 -1
- package/dist/infrastructure/school/types.d.ts +52 -3
- package/dist/infrastructure/school/types.d.ts.map +1 -1
- package/dist/infrastructure/school/types.js.map +1 -1
- package/dist/management/failures/index.d.ts +28 -2
- package/dist/management/failures/index.d.ts.map +1 -1
- package/dist/management/failures/index.js +83 -21
- package/dist/management/failures/index.js.map +1 -1
- package/package.json +7 -2
- package/school/NOTICE +3 -2
- package/school/paper_search_school/adapters/__init__.py +2 -0
- package/school/paper_search_school/adapters/aps/__init__.py +3 -6
- package/school/paper_search_school/adapters/base.py +18 -0
- package/school/paper_search_school/adapters/copernicus/__init__.py +2 -7
- package/school/paper_search_school/adapters/elsevier/__init__.py +50 -1
- package/school/paper_search_school/adapters/frontiers/__init__.py +41 -2
- package/school/paper_search_school/adapters/ieee/__init__.py +6 -4
- package/school/paper_search_school/adapters/iop/__init__.py +8 -0
- package/school/paper_search_school/adapters/jama/__init__.py +8 -0
- package/school/paper_search_school/adapters/lww/__init__.py +14 -6
- package/school/paper_search_school/adapters/mdpi/__init__.py +12 -7
- package/school/paper_search_school/adapters/neurology/__init__.py +5 -2
- package/school/paper_search_school/adapters/optica/__init__.py +2 -9
- package/school/paper_search_school/adapters/oup/__init__.py +27 -4
- package/school/paper_search_school/adapters/platforms/__init__.py +4 -1
- package/school/paper_search_school/adapters/platforms/atypon/__init__.py +8 -0
- package/school/paper_search_school/adapters/platforms/jstage/__init__.py +64 -0
- package/school/paper_search_school/adapters/sage/__init__.py +4 -1
- package/school/paper_search_school/adapters/thieme/__init__.py +6 -11
- package/school/paper_search_school/api_keys.py +63 -13
- package/school/paper_search_school/assets/api_keys.json +14 -0
- package/school/paper_search_school/assets/capsule.html +274 -158
- package/school/paper_search_school/assets/capsule_en.json +99 -98
- package/school/paper_search_school/assets/capsule_fr.json +100 -99
- package/school/paper_search_school/assets/capsule_ja.json +99 -98
- package/school/paper_search_school/assets/capsule_ko.json +99 -98
- package/school/paper_search_school/assets/capsule_zh-Hant.json +94 -97
- package/school/paper_search_school/browser/batch_session.py +1 -1
- package/school/paper_search_school/browser/challenge/__init__.py +12 -9
- package/school/paper_search_school/browser/challenge/continuation.py +65 -0
- package/school/paper_search_school/browser/challenge/handlers/__init__.py +1 -0
- package/school/paper_search_school/browser/challenge/handlers/aws_waf.py +260 -0
- package/school/paper_search_school/browser/challenge/handlers/recaptcha_hcaptcha.py +167 -0
- package/school/paper_search_school/browser/challenge/handlers/text_captcha.py +100 -0
- package/school/paper_search_school/browser/challenge/handlers/turnstile.py +174 -0
- package/school/paper_search_school/browser/challenge/kinds.py +203 -0
- package/school/paper_search_school/browser/challenge/local/__init__.py +1 -0
- package/school/paper_search_school/browser/challenge/{interaction.py → local/interaction.py} +94 -13
- package/school/paper_search_school/browser/challenge/{pointer.py → local/pointer.py} +2 -2
- package/school/paper_search_school/browser/challenge/local/prompt.py +283 -0
- package/school/paper_search_school/browser/challenge/local/submission.py +33 -0
- package/school/paper_search_school/browser/challenge/services/__init__.py +1 -0
- package/school/paper_search_school/browser/challenge/services/solver.py +272 -0
- package/school/paper_search_school/cli_config.py +10 -5
- package/school/paper_search_school/cold_start.py +22 -11
- package/school/paper_search_school/config.py +11 -10
- package/school/paper_search_school/download_diagnostics.py +7 -2
- package/school/paper_search_school/engine/access_rules.py +15 -5
- package/school/paper_search_school/engine/batch.py +55 -15
- package/school/paper_search_school/engine/batch_access.py +59 -21
- package/school/paper_search_school/engine/batch_capture.py +215 -18
- package/school/paper_search_school/engine/batch_common.py +3 -0
- package/school/paper_search_school/engine/batch_diagnostics.py +25 -5
- package/school/paper_search_school/engine/batch_institution.py +168 -32
- package/school/paper_search_school/engine/batch_login.py +223 -16
- package/school/paper_search_school/engine/batch_pdf_urls.py +38 -7
- package/school/paper_search_school/engine/batch_waits.py +179 -12
- package/school/paper_search_school/engine/bridge.py +44 -7
- package/school/paper_search_school/engine/fulltext_page.py +45 -7
- package/school/paper_search_school/engine/router.py +18 -2
- package/school/paper_search_school/entitlements.py +1 -1
- package/school/paper_search_school/orchestrator.py +44 -18
- package/school/paper_search_school/pdf_utils.py +25 -16
- package/school/paper_search_school/progress_capsule.py +36 -6
- package/school/paper_search_school/progress_reporter.py +71 -13
- package/school/paper_search_school/progress_view.py +64 -44
- package/school/paper_search_school/publishers/builtin/iop.json +2 -1
- package/school/paper_search_school/publishers/builtin/neurology.json +4 -2
- package/school/paper_search_school/publishers/builtin/sage.json +4 -2
- package/school/paper_search_school/publishers/builtin/thieme.json +3 -1
- package/school/paper_search_school/publishers/site.py +12 -4
- package/school/paper_search_school/school_switch.py +34 -52
- package/school/paper_search_school/school_test.py +1 -1
- package/school/paper_search_school/server.py +24 -11
- package/school/paper_search_school/user_settings.py +13 -0
- package/school/pyproject.toml +1 -0
- package/skills/paper-search/SKILL.md +107 -107
- package/skills/paper-search/references/browser-download.md +102 -101
- package/skills/paper-search/references/capability-routing.md +89 -89
- package/skills/paper-search/references/cli-contract.md +78 -78
- package/skills/paper-search/references/federation-support.md +172 -172
- package/skills/paper-search/references/management-layer.md +78 -78
- package/skills/paper-search/references/publisher-support.md +38 -38
- package/skills/paper-search/references/school-setup.md +56 -55
- package/skills/paper-search/references/setup.md +20 -20
- package/skills/paper-search/references/troubleshooting.md +12 -12
- package/school/paper_search_school/browser/challenge/prompt.py +0 -154
|
@@ -96,6 +96,7 @@ class LoginMixin:
|
|
|
96
96
|
# or looking for an institution entry that cannot exist on it.
|
|
97
97
|
if not self._wait_for_challenge(page, result):
|
|
98
98
|
return False
|
|
99
|
+
self._note_article_host(page)
|
|
99
100
|
self._raise_on_publisher_content_error(page)
|
|
100
101
|
self._dismiss_cookie_banners(page, result)
|
|
101
102
|
snapshot = self._access_snapshot(page) if not self._is_auth_page(str(page.url)) else None
|
|
@@ -237,9 +238,11 @@ class LoginMixin:
|
|
|
237
238
|
|
|
238
239
|
def _reopen_after_gateway_error(self, page: Any, result: DownloadResult) -> None:
|
|
239
240
|
"""Open the article again, once, when the publisher's front proxy answered
|
|
240
|
-
with its bare error page instead (its server did not answer in time)
|
|
241
|
-
|
|
242
|
-
|
|
241
|
+
with its bare error page instead (its server did not answer in time), or the
|
|
242
|
+
site with its own page for a fault on its side (the adapter's
|
|
243
|
+
``server_error_page``). The same page again is the publisher's error,
|
|
244
|
+
reported as such."""
|
|
245
|
+
error = self._server_error_text(page)
|
|
243
246
|
if not error:
|
|
244
247
|
return
|
|
245
248
|
self._event(result, "gateway_error_page", error[:160])
|
|
@@ -247,10 +250,13 @@ class LoginMixin:
|
|
|
247
250
|
open_page(page, result.article_url, timeout_ms=60_000)
|
|
248
251
|
settle(page, 3_000)
|
|
249
252
|
self._wait_past_redirect_page(page, result)
|
|
250
|
-
error = self.
|
|
253
|
+
error = self._server_error_text(page)
|
|
251
254
|
if error:
|
|
252
255
|
raise PublisherContentError(f"publisher_gateway_error: {error[:120]}")
|
|
253
256
|
|
|
257
|
+
def _server_error_text(self, page: Any) -> str:
|
|
258
|
+
return self._gateway_error_text(page) or self.adapter.server_error_page(page)
|
|
259
|
+
|
|
254
260
|
def _complete_login_from_current_page(self, page: Any, result: DownloadResult) -> bool:
|
|
255
261
|
"""The school's login from the current page (``_complete_login_steps``), then
|
|
256
262
|
back to the article if it ended on another page (``_return_to_article_after_login``);
|
|
@@ -557,12 +563,19 @@ class LoginMixin:
|
|
|
557
563
|
if not entry_opened and self.profile.generic and self._may_offer_entry(page):
|
|
558
564
|
# A site without rules of its own: the shared rules found no way to the
|
|
559
565
|
# school's login on its page, and there is nothing for the user to do here.
|
|
560
|
-
|
|
566
|
+
# A page whose only sign-in is the site's own account (a password field, no sign
|
|
567
|
+
# of a school route) has no school login: mathnet.ru's Sbornik: Mathematics, only
|
|
568
|
+
# "Personal entry: Login, Password", ended as 暂未适配 (Windows, 2026-11-25). Not in
|
|
569
|
+
# the login after a failed PDF, whose ending is the PDF's.
|
|
570
|
+
personal = "" if getattr(result, "_pdf_retry_login", False) else self._personal_sign_in_only(page, result)
|
|
571
|
+
result.reason = NO_INSTITUTION_ENTRY if personal else GENERIC_ENTRY_MISSING
|
|
561
572
|
looked_for, controls = self._entry_lookup_evidence(page)
|
|
573
|
+
if personal:
|
|
574
|
+
self._event(result, NO_INSTITUTION_ENTRY, personal)
|
|
562
575
|
self._event(result, "login_entry_missing", looked_for)
|
|
563
576
|
self._event(result, "login_entry_controls", controls)
|
|
564
|
-
self._snapshot(page, result, "login entry missing")
|
|
565
|
-
self._remember_no_entry(page, result,
|
|
577
|
+
self._snapshot(page, result, "personal account sign-in only" if personal else "login entry missing")
|
|
578
|
+
self._remember_no_entry(page, result, result.reason)
|
|
566
579
|
return False
|
|
567
580
|
if (manual_selection and self.adapter.requires_institution_entry and not entry_opened
|
|
568
581
|
and not self._is_human_login_page(page)):
|
|
@@ -578,12 +591,18 @@ class LoginMixin:
|
|
|
578
591
|
self._event(result, "login_entry_missing",
|
|
579
592
|
f"{str(page.url)[:160]} | no institution entry, access menu entry or institution sign-in link")
|
|
580
593
|
self._snapshot(page, result, "login entry missing")
|
|
594
|
+
self._no_login_off_publisher(page, result)
|
|
581
595
|
return False
|
|
582
596
|
settle(page, 5_000)
|
|
583
597
|
self._dismiss_cookie_banners(page, result)
|
|
584
598
|
if self._click_openathens_entry(page, result):
|
|
585
599
|
settle(page, 2_000)
|
|
586
|
-
self.
|
|
600
|
+
if not (self._on_login_site(page, result) and self._article_access_available(page)):
|
|
601
|
+
# On the login site's article, already given to the reader, there is no school to
|
|
602
|
+
# choose: the wait's first pass ends there. ScienceDirect's open article for
|
|
603
|
+
# jacc.org was taken as a page to choose the school on (institution_selection_required,
|
|
604
|
+
# then a page wait), Windows 2026-11-23.
|
|
605
|
+
self._select_institution(page, result)
|
|
587
606
|
if not entry_opened and self._no_school_route(page, result, sites_opened):
|
|
588
607
|
return False
|
|
589
608
|
|
|
@@ -597,6 +616,7 @@ class LoginMixin:
|
|
|
597
616
|
outside_since = time.time() # last seen on the user's own login step
|
|
598
617
|
article_returns = 0
|
|
599
618
|
session_returns = 0
|
|
619
|
+
no_entry_since = 0.0 # since when the page has stood as the article's own, nothing to open on it
|
|
600
620
|
away_from_publisher = False # on an IdP, federation or chooser page since the last probe
|
|
601
621
|
returned = False # back on the publisher's site after such a page: try the PDF
|
|
602
622
|
last_probe = time.time()
|
|
@@ -628,6 +648,15 @@ class LoginMixin:
|
|
|
628
648
|
f"{self._login_wait_page(page)} after {self.page_wait_sec:.0f} s")
|
|
629
649
|
self._wait_ran_out(result)
|
|
630
650
|
return False
|
|
651
|
+
if not entry_opened and self._article_without_entry(page, result, sites_opened):
|
|
652
|
+
# Looked for again on every pass below (an entry drawn late): none for ENTRY_LOOK_SEC, the
|
|
653
|
+
# login has nothing to wait for (_end_without_entry), not the whole page wait.
|
|
654
|
+
no_entry_since = no_entry_since or time.time()
|
|
655
|
+
if time.time() - no_entry_since >= self.ENTRY_LOOK_SEC:
|
|
656
|
+
self._end_without_entry(page, result)
|
|
657
|
+
return False
|
|
658
|
+
else:
|
|
659
|
+
no_entry_since = 0.0
|
|
631
660
|
# Navigation and auto-submit can finish during the preceding
|
|
632
661
|
# wait. Never publish the classification of the old document.
|
|
633
662
|
user_step = self._users_login_step(page)
|
|
@@ -672,6 +701,10 @@ class LoginMixin:
|
|
|
672
701
|
if getattr(result, "_visited_idp", False):
|
|
673
702
|
result._login_round_trip = True
|
|
674
703
|
self._event(result, "login_round_trip_returned", here.geturl()[:160])
|
|
704
|
+
if getattr(result, "_route_round_trip", False):
|
|
705
|
+
# Back from the school's side by the login's route, unseen by this wait (_note_route_hop): the
|
|
706
|
+
# next try of the PDF is the one after the login, as when the wait saw it come back.
|
|
707
|
+
result._route_round_trip, returned = False, True
|
|
675
708
|
if (on_publisher and self._is_success_article_url(here.geturl())
|
|
676
709
|
and not self._is_auth_page(here.geturl()) and not self._challenge_shell(page)
|
|
677
710
|
and (returned or time.time() - last_probe >= self.WAIT_PROBE_EVERY_SEC)
|
|
@@ -704,6 +737,14 @@ class LoginMixin:
|
|
|
704
737
|
# 2026-11-17), and the page read before it is read again.
|
|
705
738
|
result._login_round_trip = True
|
|
706
739
|
return True
|
|
740
|
+
if self._at_login_landing(here.geturl(), result):
|
|
741
|
+
# From the login landing the login went round as well, though the article
|
|
742
|
+
# is still offered or denied: the next pass tries the PDF and, with the
|
|
743
|
+
# page's evidence, ends the wait as not subscribed. NEJM Catalyst
|
|
744
|
+
# (10.1056/cat.25.0121, Windows 2026-11-23): the school's sign-in kept from
|
|
745
|
+
# the paper before, authenticateSharedSP, "Get Access" again; the wait ran
|
|
746
|
+
# out on the article (login_not_reached).
|
|
747
|
+
result._login_round_trip = returned = True
|
|
707
748
|
except Exception as exc:
|
|
708
749
|
self._event(result, "idp_return_article_error", type(exc).__name__)
|
|
709
750
|
continue
|
|
@@ -1342,6 +1383,15 @@ class LoginMixin:
|
|
|
1342
1383
|
self._event(result, "login_page_opened", target)
|
|
1343
1384
|
return True
|
|
1344
1385
|
|
|
1386
|
+
@staticmethod
|
|
1387
|
+
def _on_login_site(page: Any, result: DownloadResult | None) -> bool:
|
|
1388
|
+
"""The page is on the site the adapter sent this item's login to
|
|
1389
|
+
(``_open_adapter_login_page``: ScienceDirect's same article for an Elsevier
|
|
1390
|
+
journal's own site), not on the site the login came from."""
|
|
1391
|
+
source = str(getattr(result, "_login_site_from", "") or "") if result is not None else ""
|
|
1392
|
+
host = (urlparse(str(getattr(page, "url", "") or "")).hostname or "").lower()
|
|
1393
|
+
return bool(source and host and host != (urlparse(source).hostname or "").lower())
|
|
1394
|
+
|
|
1345
1395
|
def _return_from_login_site(self, page: Any, result: DownloadResult) -> bool:
|
|
1346
1396
|
"""The adapter sent the login to another site (an Elsevier journal site's
|
|
1347
1397
|
institution login is ScienceDirect's). Once that site shows the institution
|
|
@@ -1349,12 +1399,22 @@ class LoginMixin:
|
|
|
1349
1399
|
2026-10-31), open the article again on the journal's own site: whether the school
|
|
1350
1400
|
has access, and which PDF to take, is that site's to answer. If the journal
|
|
1351
1401
|
site still gives only the abstract, go back once to the login site's
|
|
1352
|
-
article, which then decides as before. True when navigated.
|
|
1402
|
+
article, which then decides as before. True when navigated.
|
|
1403
|
+
|
|
1404
|
+
Not in the login after a failed PDF: the journal's site has refused that PDF
|
|
1405
|
+
already, and the login site's article decides. Giving the article, its PDF is
|
|
1406
|
+
taken there (``_article_access_available``); denying it to the school's session,
|
|
1407
|
+
the school has no access (``_login_block_reason``). jacc.org
|
|
1408
|
+
(10.1016/j.jcmg.2025.09.021, Windows 2026-11-23): "This is an Open Access Article"
|
|
1409
|
+
by "GET ACCESS", its PDF 403; ScienceDirect's same article showed "Open access" and
|
|
1410
|
+
its full text, and the login waited a page wait there and ended as pdf_not_captured."""
|
|
1353
1411
|
url = str(getattr(page, "url", "") or "")
|
|
1354
1412
|
host = (urlparse(url).hostname or "").lower()
|
|
1355
1413
|
source = getattr(result, "_login_site_from", "")
|
|
1356
1414
|
fallback = getattr(result, "_login_site_fallback", "")
|
|
1357
1415
|
if source and host != (urlparse(source).hostname or "").lower():
|
|
1416
|
+
if getattr(result, "_pdf_retry_login", False):
|
|
1417
|
+
return False
|
|
1358
1418
|
if not (self._has_publisher_institution_session(page) or self._article_access_available(page)):
|
|
1359
1419
|
return False
|
|
1360
1420
|
result._login_site_from, result._login_site_fallback = "", url
|
|
@@ -1479,6 +1539,29 @@ class LoginMixin:
|
|
|
1479
1539
|
return null;
|
|
1480
1540
|
}"""
|
|
1481
1541
|
|
|
1542
|
+
# In an opened access menu only: its "Check Access" when the panel around it says the access is an
|
|
1543
|
+
# institution's. APA PsycNET's "Get Access" panel: "You may have access to this content with your personal
|
|
1544
|
+
# login credentials or through your institutional subscription. CHECK ACCESS", which opens its sign-in page
|
|
1545
|
+
# with the institutions' list (select#entityID); no entry was found there (2026-11-24). Elsewhere "Check
|
|
1546
|
+
# Access" is an offer (access_rules.OFFER_LABEL).
|
|
1547
|
+
_MENU_CHECK_ACCESS_JS = r"""() => {
|
|
1548
|
+
const shown = el => el.getClientRects().length > 0 && getComputedStyle(el).visibility !== 'hidden';
|
|
1549
|
+
const controls = [...document.querySelectorAll('a, button, [role="button"]')];
|
|
1550
|
+
for (const [index, el] of controls.entries()) {
|
|
1551
|
+
const label = (el.innerText || el.getAttribute('aria-label') || '').replace(/\s+/g, ' ').trim();
|
|
1552
|
+
if (!shown(el) || !/^check access$/i.test(label)) continue;
|
|
1553
|
+
for (let panel = el.parentElement, n = 0; panel && panel !== document.body && n < 6; panel = panel.parentElement, n++) {
|
|
1554
|
+
const text = (panel.innerText || '').replace(/\s+/g, ' ');
|
|
1555
|
+
if (text.length > 1500) break;
|
|
1556
|
+
if (/\binstitution(?:al)?\b/i.test(text)) {
|
|
1557
|
+
const href = el.tagName === 'A' && el.href && !/^javascript:/i.test(el.href) ? el.href : '';
|
|
1558
|
+
return {label: label.slice(0, 120), href, index};
|
|
1559
|
+
}
|
|
1560
|
+
}
|
|
1561
|
+
}
|
|
1562
|
+
return null;
|
|
1563
|
+
}"""
|
|
1564
|
+
|
|
1482
1565
|
def _open_entry_from_access_menu(self, page: Any, result: DownloadResult | None) -> bool:
|
|
1483
1566
|
"""Open the site's access menu once per page and take the institution entry
|
|
1484
1567
|
inside it: the adapter's own rule, else ``_INSTITUTION_ENTRY_JS``. An
|
|
@@ -1495,10 +1578,11 @@ class LoginMixin:
|
|
|
1495
1578
|
result._access_menus = tried | {url} # opened once: a second click would close it
|
|
1496
1579
|
self._event(result, "access_menu_opened", str(label)[:120])
|
|
1497
1580
|
entry = None
|
|
1498
|
-
if pump_until(page, lambda: bool(page.evaluate(self._INSTITUTION_ENTRY_JS)
|
|
1581
|
+
if pump_until(page, lambda: bool(page.evaluate(self._INSTITUTION_ENTRY_JS)
|
|
1582
|
+
or page.evaluate(self._MENU_CHECK_ACCESS_JS)), 2_500):
|
|
1499
1583
|
if self.adapter.open_institution_entry(page, result):
|
|
1500
1584
|
return True
|
|
1501
|
-
entry = page.evaluate(self._INSTITUTION_ENTRY_JS)
|
|
1585
|
+
entry = page.evaluate(self._INSTITUTION_ENTRY_JS) or page.evaluate(self._MENU_CHECK_ACCESS_JS)
|
|
1502
1586
|
if not isinstance(entry, dict):
|
|
1503
1587
|
return False
|
|
1504
1588
|
href = str(entry.get("href") or "")
|
|
@@ -1547,6 +1631,8 @@ class LoginMixin:
|
|
|
1547
1631
|
"button:has-text('Institutional Access')",
|
|
1548
1632
|
"a:has-text('Institutional Access')",
|
|
1549
1633
|
"button:has-text('Institutional Sign In')",
|
|
1634
|
+
"a:has-text('Change institution')",
|
|
1635
|
+
"button:has-text('Change institution')",
|
|
1550
1636
|
)
|
|
1551
1637
|
sso_selectors = (*self.adapter.sso_selectors, *sso_selectors)
|
|
1552
1638
|
for selector in sso_selectors:
|
|
@@ -1600,7 +1686,8 @@ class LoginMixin:
|
|
|
1600
1686
|
'log in via your institution',
|
|
1601
1687
|
'provided by your institution',
|
|
1602
1688
|
'username/password provided by your institution',
|
|
1603
|
-
'log in with username/password provided by your institution'
|
|
1689
|
+
'log in with username/password provided by your institution',
|
|
1690
|
+
'change institution'
|
|
1604
1691
|
];
|
|
1605
1692
|
const clickableSelector = 'a,button,[role="button"],input[type="button"],input[type="submit"]';
|
|
1606
1693
|
const textOf = (el) => [
|
|
@@ -1663,7 +1750,7 @@ class LoginMixin:
|
|
|
1663
1750
|
"""A page of the publisher's own where its institution entry would be: not
|
|
1664
1751
|
a login, IdP or chooser page, no verification, no school login form."""
|
|
1665
1752
|
url = str(getattr(page, "url", "") or "")
|
|
1666
|
-
return (url.startswith("http") and self.
|
|
1753
|
+
return (url.startswith("http") and self._on_landing_site(url) and not self._is_auth_page(url)
|
|
1667
1754
|
and not self._challenge_shell(page) and not self._is_human_login_page(page))
|
|
1668
1755
|
|
|
1669
1756
|
# The page's own sign-in and access controls, for the record of a missing entry.
|
|
@@ -1867,6 +1954,69 @@ class LoginMixin:
|
|
|
1867
1954
|
self._remember_no_entry(page, result, NO_INSTITUTION_ENTRY)
|
|
1868
1955
|
return True
|
|
1869
1956
|
|
|
1957
|
+
def _no_login_off_publisher(self, page: Any, result: DownloadResult) -> None:
|
|
1958
|
+
"""The login after a failed PDF found no institution entry on a site its publisher's rules do not
|
|
1959
|
+
name and the page shows no sign of a school route (``_route_probe``): the reason is the site's
|
|
1960
|
+
(``NO_INSTITUTION_ENTRY``), kept for the batch, not the PDF's. The PDF was looked for by the
|
|
1961
|
+
publisher's rules, on its own site, which says nothing of this one: Springer Nature's DOIs that
|
|
1962
|
+
open springermedizin.de, springerprofessional.de or scientificamerican.com (the PDF address 404,
|
|
1963
|
+
no school login) ended as 原因不明 · 没取到 PDF, the next paper of the same site as 网站不提供学校登录
|
|
1964
|
+
(Windows 2026-11-24). On the publisher's own site the PDF's reason stays: its rules may be at fault."""
|
|
1965
|
+
url = str(getattr(page, "url", "") or "")
|
|
1966
|
+
if (not url.startswith("http") or self.profile.generic or self._on_publisher_host(url)
|
|
1967
|
+
or not self._on_landing_site(url) or self._is_auth_page(url) or self._school_login_done()):
|
|
1968
|
+
return
|
|
1969
|
+
probe = self._route_probe(page)
|
|
1970
|
+
if probe is None or probe["signs"]:
|
|
1971
|
+
return
|
|
1972
|
+
result.reason = NO_INSTITUTION_ENTRY
|
|
1973
|
+
self._event(result, NO_INSTITUTION_ENTRY,
|
|
1974
|
+
f"{url[:160]} | a site the publisher's rules do not name: no PDF, no school login entry")
|
|
1975
|
+
self._remember_no_entry(page, result, NO_INSTITUTION_ENTRY)
|
|
1976
|
+
|
|
1977
|
+
# The controls a school is searched for in, on a publisher's page (the CARSI-mode entry's own check).
|
|
1978
|
+
_INSTITUTION_SEARCH_BOX = ('input[name*="institution" i]:visible, input[placeholder*="institution" i]:visible, '
|
|
1979
|
+
'input[name*="school" i]:visible, input[placeholder*="school" i]:visible')
|
|
1980
|
+
|
|
1981
|
+
# How long the article's own page may stand with no entry opened on it and nothing chosen before the
|
|
1982
|
+
# login ends (``_end_without_entry``): the entry is looked for again on every pass of the wait meanwhile
|
|
1983
|
+
# (one drawn late, ScienceDirect's after linkinghub), and the PDF tried once (WAIT_PROBE_EVERY_SEC).
|
|
1984
|
+
ENTRY_LOOK_SEC = 20
|
|
1985
|
+
|
|
1986
|
+
def _article_without_entry(self, page: Any, result: DownloadResult, sites_opened: int) -> bool:
|
|
1987
|
+
"""The page is still the article's own on the publisher's site, no login page was opened, no school
|
|
1988
|
+
chosen or reached, and it shows no chooser, no institution search box and nobody typing: nothing for
|
|
1989
|
+
a school's login there. Not a redirect, a login, chooser or verification page."""
|
|
1990
|
+
url = str(getattr(page, "url", "") or "")
|
|
1991
|
+
if (sum(e["state"] == "login_page_opened" for e in result.events) > sites_opened
|
|
1992
|
+
or getattr(result, "_institution_not_listed", False)
|
|
1993
|
+
or any(e["state"] in self._SCHOOL_CHOSEN for e in result.events) or self._school_login_done()
|
|
1994
|
+
or not url.startswith("http") or self.adapter.is_redirect_page(url) or self._is_auth_page(url)
|
|
1995
|
+
or not self._on_landing_site(url) or not self._is_success_article_url(url)
|
|
1996
|
+
or self._is_human_login_page(page) or self._challenge_shell(page)):
|
|
1997
|
+
return False
|
|
1998
|
+
try:
|
|
1999
|
+
searching = page.locator(self._INSTITUTION_SEARCH_BOX).count()
|
|
2000
|
+
except Exception as exc:
|
|
2001
|
+
if not _is_browser_error(exc):
|
|
2002
|
+
raise
|
|
2003
|
+
return False
|
|
2004
|
+
return not ((isinstance(searching, int) and searching > 0) or self._has_visible_editable_input(page)
|
|
2005
|
+
or self.adapter.institution_chooser_open(page))
|
|
2006
|
+
|
|
2007
|
+
def _end_without_entry(self, page: Any, result: DownloadResult) -> None:
|
|
2008
|
+
"""The login ends on the article's own page that stood ``ENTRY_LOOK_SEC`` with no entry the rules
|
|
2009
|
+
could open (``_article_without_entry``): ``publisher_institution_entry_missing``, PaperSearch's to fix.
|
|
2010
|
+
nature.com's Nature Cities (Windows 2026-11-24) stood the whole page wait on its article, its entry
|
|
2011
|
+
not one the rules knew, then 原因不明 · 没进入学校登录页."""
|
|
2012
|
+
url = str(getattr(page, "url", "") or "")
|
|
2013
|
+
result.reason = "publisher_institution_entry_missing"
|
|
2014
|
+
looked_for, controls = self._entry_lookup_evidence(page)
|
|
2015
|
+
self._event(result, "login_entry_missing",
|
|
2016
|
+
f"{url[:160]} | no entry opened on the article's page in {self.ENTRY_LOOK_SEC} s; {looked_for}")
|
|
2017
|
+
self._event(result, "login_entry_controls", controls)
|
|
2018
|
+
self._snapshot(page, result, "login entry missing")
|
|
2019
|
+
|
|
1870
2020
|
# The publisher's own account sign-in, with no school entry on it, is never the school's
|
|
1871
2021
|
# login: the wait ends once it has stood this long (time for an institutional option
|
|
1872
2022
|
# drawn late by script to show).
|
|
@@ -1884,7 +2034,7 @@ class LoginMixin:
|
|
|
1884
2034
|
typing. A form the user fills stays theirs."""
|
|
1885
2035
|
url = str(getattr(page, "url", "") or "")
|
|
1886
2036
|
parsed = urlparse(url)
|
|
1887
|
-
if (parsed.scheme not in ("http", "https") or not self.
|
|
2037
|
+
if (parsed.scheme not in ("http", "https") or not self._on_landing_site(url)
|
|
1888
2038
|
or self._is_idp_host(parsed.netloc) or self._on_school_login_page(url)
|
|
1889
2039
|
or self._is_federation_chooser(url) or self._school_login_done()
|
|
1890
2040
|
or (result is not None and any(e.get("state") in self._SCHOOL_CHOSEN for e in result.events))):
|
|
@@ -1933,7 +2083,10 @@ class LoginMixin:
|
|
|
1933
2083
|
"""An earlier paper of this batch found no school login entry on this site's page
|
|
1934
2084
|
(``login_routes.no_entry_since``) and this page shows none either: ended at once,
|
|
1935
2085
|
nothing looked for or clicked, with that paper's reason. The login after a failed PDF
|
|
1936
|
-
ends as the
|
|
2086
|
+
ends as it does on the page itself (``_complete_login_steps``): on a site without rules
|
|
2087
|
+
the shared rules found no entry (``GENERIC_ENTRY_MISSING``), elsewhere the PDF's reason
|
|
2088
|
+
is kept. jle.com (10.1684/ndt.2025.156, Windows 2026-11-23): the first paper ended so,
|
|
2089
|
+
the second, its PDF 403 "Accès refusé", as pdf_not_captured, tried again at the end."""
|
|
1937
2090
|
from .. import login_routes, progress_reporter
|
|
1938
2091
|
|
|
1939
2092
|
host = (urlparse(str(getattr(page, "url", "") or "")).hostname or "").lower()
|
|
@@ -1951,6 +2104,13 @@ class LoginMixin:
|
|
|
1951
2104
|
f"none on this page either")
|
|
1952
2105
|
if not getattr(result, "_pdf_retry_login", False):
|
|
1953
2106
|
result.reason = reason
|
|
2107
|
+
elif self.profile.generic:
|
|
2108
|
+
result.reason = GENERIC_ENTRY_MISSING
|
|
2109
|
+
elif not self._on_publisher_host(str(getattr(page, "url", "") or "")):
|
|
2110
|
+
# A site its publisher's rules do not name: the PDF was looked for by those rules, on the publisher's own
|
|
2111
|
+
# site, which says nothing of this one; the reason is the site's (Scientific American in Springer Nature's
|
|
2112
|
+
# list, Windows 2026-11-24: nature.com's address 404, then 原因不明 · 没取到 PDF).
|
|
2113
|
+
result.reason = reason
|
|
1954
2114
|
return True
|
|
1955
2115
|
|
|
1956
2116
|
def _remember_no_entry(self, page: Any, result: DownloadResult, reason: str) -> None:
|
|
@@ -1977,11 +2137,15 @@ class LoginMixin:
|
|
|
1977
2137
|
("/institutionlogin", "/idp/", "/entity/"))
|
|
1978
2138
|
|
|
1979
2139
|
# The labels of an institution entry, the whole label in lower case (CARSI mode).
|
|
2140
|
+
# "Change institution": a site that knows the reader's institution and denies the article to it
|
|
2141
|
+
# (nature.com's "Access to this article via <consortium> is not available", Nature Cities, Windows
|
|
2142
|
+
# 2026-11-24) opens its chooser from there; the school's own login then tells whether the school has it.
|
|
1980
2143
|
_INSTITUTION_ENTRY_LABELS = frozenset({
|
|
1981
2144
|
"access through your institution", "access through institution",
|
|
1982
2145
|
"access through your organization", "institutional access",
|
|
1983
2146
|
"institutional login", "institutional sign in", "log in via an institution",
|
|
1984
2147
|
"log in through your institution", "log in via your institution", "log in via institution",
|
|
2148
|
+
"change institution",
|
|
1985
2149
|
})
|
|
1986
2150
|
|
|
1987
2151
|
def _click_manual_institution_entry(self, page: Any, result: DownloadResult | None) -> bool:
|
|
@@ -2003,19 +2167,41 @@ class LoginMixin:
|
|
|
2003
2167
|
if control.evaluate("el => el.tagName !== 'A' && Boolean(el.form || el.closest('form'))"):
|
|
2004
2168
|
continue
|
|
2005
2169
|
href = control.get_attribute("href", timeout=2_000) or control.get_attribute("formaction", timeout=2_000) or ""
|
|
2170
|
+
# A link whose address only the site's script follows (ASCO's
|
|
2171
|
+
# <a data-href="/action/ssostart">, 2026-11-25).
|
|
2172
|
+
scripted = "" if href else (control.get_attribute("data-href", timeout=2_000) or "")
|
|
2006
2173
|
except Exception as exc:
|
|
2007
2174
|
if not _is_browser_error(exc):
|
|
2008
2175
|
raise
|
|
2009
2176
|
continue # gone or changed while the page moved on (JAMA Pediatrics, 2026-11-02)
|
|
2010
2177
|
if href and not self._manual_institution_target_allowed(urljoin(str(page.url), href)):
|
|
2011
2178
|
continue
|
|
2179
|
+
before = str(getattr(page, "url", "") or "")
|
|
2012
2180
|
if not self._click_control(page, control, result, f"institution entry: {label.strip()[:80]}"):
|
|
2013
2181
|
continue # nothing was clicked (script_click_failed)
|
|
2014
2182
|
if result is not None:
|
|
2015
2183
|
self._event(result, "sso_entry_clicked", "generic-institution-chooser")
|
|
2184
|
+
if scripted:
|
|
2185
|
+
self._follow_scripted_entry(page, result, before, urljoin(before, scripted))
|
|
2016
2186
|
return True
|
|
2017
2187
|
return False
|
|
2018
2188
|
|
|
2189
|
+
# How long a clicked entry whose address only the site's script follows may leave the page on its own.
|
|
2190
|
+
SCRIPTED_ENTRY_WAIT_MS = 5_000
|
|
2191
|
+
|
|
2192
|
+
def _follow_scripted_entry(self, page: Any, result: DownloadResult | None, before: str, target: str) -> None:
|
|
2193
|
+
"""The entry's own address opened when its click left the page where it was:
|
|
2194
|
+
ASCO's "INSTITUTIONAL LOGIN" (``data-href="/action/ssostart"``) answered a
|
|
2195
|
+
click that timed out, then the script's click, only now and then; the other
|
|
2196
|
+
times the login wait ran its minute on the article page (2026-11-25). Only
|
|
2197
|
+
an address the chooser may open (``_manual_institution_target_allowed``)."""
|
|
2198
|
+
pump_until(page, lambda: str(getattr(page, "url", "") or "") != before, self.SCRIPTED_ENTRY_WAIT_MS)
|
|
2199
|
+
if str(getattr(page, "url", "") or "") != before or not self._manual_institution_target_allowed(target):
|
|
2200
|
+
return
|
|
2201
|
+
open_page(page, target, timeout_ms=30_000)
|
|
2202
|
+
if result is not None:
|
|
2203
|
+
self._event(result, "sso_entry_opened", f"the entry's own address: {urlparse(target).path[:80]}")
|
|
2204
|
+
|
|
2019
2205
|
def _has_visible_editable_input(self, page: Any) -> bool:
|
|
2020
2206
|
"""Someone may be typing here: a visible editable field holds a value. Read
|
|
2021
2207
|
on every pass of the login wait; a page navigating meanwhile ("Execution
|
|
@@ -2069,6 +2255,27 @@ class LoginMixin:
|
|
|
2069
2255
|
return True
|
|
2070
2256
|
return self.adapter.is_article_page_url(url) is True
|
|
2071
2257
|
|
|
2258
|
+
def _on_landing_site(self, url: str) -> bool:
|
|
2259
|
+
"""The publisher's own site (``_on_publisher_host``), or the site this paper's article opened on
|
|
2260
|
+
past its DOI's redirects (``_note_article_host``), which no profile may name: Nature Digest's
|
|
2261
|
+
natureasia.com in Springer Nature's list, whose personal subscribers' sign-in was taken for the
|
|
2262
|
+
school's login page and held the publisher's 73 other papers, again after each 登录并继续
|
|
2263
|
+
(Windows, 2026-11-24)."""
|
|
2264
|
+
host = (urlparse(url).hostname or "").lower()
|
|
2265
|
+
return self._on_publisher_host(url) or bool(host) and host == getattr(self, "_article_host", "")
|
|
2266
|
+
|
|
2267
|
+
def _note_article_host(self, page: Any) -> None:
|
|
2268
|
+
"""The site the article opened on (``_on_landing_site``): not one on the school's side, a
|
|
2269
|
+
login, chooser or federation page, nor one this paper's login has gone on to."""
|
|
2270
|
+
url = str(getattr(page, "url", "") or "")
|
|
2271
|
+
parsed = urlparse(url)
|
|
2272
|
+
host = (parsed.hostname or "").lower()
|
|
2273
|
+
if (parsed.scheme not in ("http", "https") or not host or getattr(self, "_route_away", False)
|
|
2274
|
+
or self._is_idp_host(host) or self._on_school_login_page(url) or self._is_auth_page(url)
|
|
2275
|
+
or self._is_federation_chooser(url) or self._school_login_done()):
|
|
2276
|
+
return
|
|
2277
|
+
self._article_host = host
|
|
2278
|
+
|
|
2072
2279
|
def _page_wait_over(self, page: Any, outside_since: float) -> tuple[bool, float]:
|
|
2073
2280
|
"""Whether a login wait has been off the user's own login step for a whole
|
|
2074
2281
|
page wait, and when that step was last seen (now, when on it)."""
|
|
@@ -2155,7 +2362,7 @@ class LoginMixin:
|
|
|
2155
2362
|
return "authentication_redirect"
|
|
2156
2363
|
if self._is_auth_page(url):
|
|
2157
2364
|
return "institution_chooser" if self.institution_query else "school_choice"
|
|
2158
|
-
return "publisher" if self.
|
|
2365
|
+
return "publisher" if self._on_landing_site(url) else "other"
|
|
2159
2366
|
|
|
2160
2367
|
def _is_human_login_page(self, page: Any) -> bool:
|
|
2161
2368
|
url = str(getattr(page, "url", "") or "")
|
|
@@ -9,7 +9,8 @@ from fnmatch import fnmatch
|
|
|
9
9
|
from typing import Any
|
|
10
10
|
from urllib.parse import unquote, urlparse
|
|
11
11
|
|
|
12
|
-
from .router import build_pdf_candidates, extract_elsevier_pii, is_pdf_candidate_url,
|
|
12
|
+
from .router import (OJS_VIEW_PATH, PLATFORM_FILE_PATH, build_pdf_candidates, extract_elsevier_pii, is_pdf_candidate_url,
|
|
13
|
+
is_supplementary_url, is_springer_article_pdf_url)
|
|
13
14
|
from .batch_common import PaperRecord, _REFERENCE_AREA, _is_browser_error
|
|
14
15
|
|
|
15
16
|
|
|
@@ -24,22 +25,45 @@ _NOT_PDF_LINK = re.compile(
|
|
|
24
25
|
r"|password|/ads?/|doubleclick|addtoany", re.I)
|
|
25
26
|
# A path that serves a PDF: a .pdf file or a PDF view (Wiley /doi/pdf|epdf|pdfdirect/,
|
|
26
27
|
# ScienceDirect /pdfft, RSC /articlepdf/, Elsevier journals' /action/showPdf, IEEE's
|
|
27
|
-
# stamp.jsp and stampPDF, Optica's viewmedia.cfm, PLOS's /article/file)
|
|
28
|
+
# stamp.jsp and stampPDF, Optica's viewmedia.cfm, PLOS's /article/file), or a platform's file
|
|
29
|
+
# (router.PLATFORM_FILE_PATH: an Open Journal Systems galley, bepress's viewcontent.cgi).
|
|
28
30
|
_PDF_PATH = re.compile(
|
|
29
31
|
r"\.pdf$|/(?:pdf|epdf|pdfdirect|pdfft|articlepdf|stamppdf)(?:/|$)|/action/showpdf$|/stamp/stamp\.jsp$"
|
|
30
|
-
r"|viewmedia\.cfm$|/article/file
|
|
32
|
+
r"|viewmedia\.cfm$|/article/file$|" + PLATFORM_FILE_PATH.pattern, re.I)
|
|
31
33
|
# Article views that are not an article id ("/article/123/fulltext").
|
|
32
34
|
_VIEWS = frozenset({"fulltext", "abstract", "full", "abs", "html", "pdf", "epdf", "summary", "info", "references"})
|
|
33
|
-
# The page's citation metadata and its visible links outside the references, in one round trip.
|
|
35
|
+
# The page's citation metadata and its visible links outside the references, in one round trip. A form with a
|
|
36
|
+
# control shown counts as a link to its address (with its own fields when it is sent by GET): Brepols's PDF button is
|
|
37
|
+
# a link to "#" in <form action="/deliver/fulltext/.../<article>.pdf">, sent by the page's script; the click gave no
|
|
38
|
+
# PDF and its address was never tried (Centaurus, Windows 2026-11-24). Its address still has to pass as this
|
|
39
|
+
# article's PDF (_article_pdf_link).
|
|
40
|
+
# A page without citation_doi names its DOI elsewhere: bepress Digital Commons in bepress_citation_doi (with
|
|
41
|
+
# its PDF in bepress_citation_pdf_url, Osgoode Hall Law Journal), Tellus B's site in DC.Identifier (its
|
|
42
|
+
# citation_pdf_url never tried, 2026-11-24). Those are read only when the citation_ names are missing.
|
|
34
43
|
_PAGE_PDF_LINKS_JS = """() => {
|
|
35
44
|
const shown = el => el.getClientRects().length > 0 && getComputedStyle(el).visibility !== 'hidden';
|
|
36
|
-
const meta = name => [...document.querySelectorAll('meta[name="' + name + '"]')]
|
|
45
|
+
const meta = name => [...document.querySelectorAll('meta[name="' + name + '" i]')]
|
|
37
46
|
.map(el => (el.content || '').trim()).filter(Boolean);
|
|
47
|
+
const first = (...lists) => lists.find(list => list.length) || [];
|
|
48
|
+
const doiLike = values => values.map(value => value.replace(/^(?:https?:\\/\\/(?:dx\\.)?doi\\.org\\/|doi:\\s*)/i, ''))
|
|
49
|
+
.filter(value => /^10\\.\\d{4,9}\\/\\S+$/.test(value));
|
|
38
50
|
const absolute = value => { try { return new URL(value, location.href).href; } catch (_) { return ''; } };
|
|
39
51
|
const links = [...document.querySelectorAll('a[href]')]
|
|
40
52
|
.filter(a => shown(a) && !a.closest(REFERENCES)).map(a => a.href).filter(href => /^https?:/i.test(href));
|
|
41
|
-
|
|
42
|
-
|
|
53
|
+
const forms = [...document.querySelectorAll('form[action]')]
|
|
54
|
+
.filter(f => !f.closest(REFERENCES) && [...f.querySelectorAll('a, button, input[type=submit], [role=button]')].some(shown))
|
|
55
|
+
.map(f => {
|
|
56
|
+
let target;
|
|
57
|
+
try { target = new URL(f.getAttribute('action'), location.href); } catch (_) { return ''; }
|
|
58
|
+
if ((f.getAttribute('method') || 'get').toLowerCase() === 'get') {
|
|
59
|
+
for (const [name, value] of new FormData(f)) if (typeof value === 'string') target.searchParams.append(name, value);
|
|
60
|
+
}
|
|
61
|
+
return target.href;
|
|
62
|
+
}).filter(href => /^https?:/i.test(href));
|
|
63
|
+
return {dois: first(meta('citation_doi'), meta('bepress_citation_doi'), doiLike(meta('DC.Identifier.DOI')),
|
|
64
|
+
doiLike(meta('DC.Identifier'))),
|
|
65
|
+
pdfs: first(meta('citation_pdf_url'), meta('bepress_citation_pdf_url')).map(absolute).filter(Boolean),
|
|
66
|
+
links: [...new Set([...links, ...forms])].slice(0, 800)};
|
|
43
67
|
}""".replace("REFERENCES", repr(_REFERENCE_AREA))
|
|
44
68
|
|
|
45
69
|
|
|
@@ -83,6 +107,13 @@ class PdfUrlsMixin:
|
|
|
83
107
|
ids = [part for part in segments if re.fullmatch(r"\d{5,}", part)]
|
|
84
108
|
if ids:
|
|
85
109
|
keys.append(ids[-1])
|
|
110
|
+
# On an Open Journal Systems article or galley page, that article's galley files: its
|
|
111
|
+
# "PDF" opens /article/view/<article>/<galley>, a page around the PDF whose Download is
|
|
112
|
+
# /article/download/<article>/<galley>/<file>; the article number was too short to name it
|
|
113
|
+
# (AJPR's 442) or a name (JSIHS), and that Download was never tried (2026-11-24).
|
|
114
|
+
ojs = OJS_VIEW_PATH.search(urlparse(page_url or "").path.lower())
|
|
115
|
+
if ojs:
|
|
116
|
+
keys.append(f"/article/download/{ojs.group(1)}/")
|
|
86
117
|
return [key for key in dict.fromkeys(keys) if key]
|
|
87
118
|
|
|
88
119
|
def _citation_pdf_urls(self, page: Any, doi: str, found: dict | None = None) -> list[str]:
|