papersearch 0.7.3 → 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 +389 -56
- 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 +3 -2
- package/dist/capabilities/download/batch/batchFolder.js.map +1 -1
- package/dist/capabilities/download/batch/networkLoss.d.ts +11 -2
- package/dist/capabilities/download/batch/networkLoss.d.ts.map +1 -1
- package/dist/capabilities/download/batch/networkLoss.js +24 -3
- 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 +22 -10
- 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 +2 -1
- package/dist/infrastructure/runlog/failureClass.d.ts.map +1 -1
- package/dist/infrastructure/runlog/failureClass.js +27 -4
- 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 +48 -5
- package/dist/infrastructure/school/SchoolAttempt.js.map +1 -1
- package/dist/infrastructure/school/SchoolMcpClient.d.ts +1 -0
- package/dist/infrastructure/school/SchoolMcpClient.d.ts.map +1 -1
- package/dist/infrastructure/school/SchoolMcpClient.js +18 -6
- 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 +42 -0
- 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 +23 -0
- package/dist/management/failures/index.d.ts.map +1 -1
- package/dist/management/failures/index.js +63 -18
- 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 +16 -2
- 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 +7 -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/taylor_francis/__init__.py +0 -3
- package/school/paper_search_school/adapters/thieme/__init__.py +2 -9
- 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 +156 -116
- package/school/paper_search_school/assets/capsule_en.json +69 -46
- package/school/paper_search_school/assets/capsule_fr.json +70 -47
- package/school/paper_search_school/assets/capsule_ja.json +69 -46
- package/school/paper_search_school/assets/capsule_ko.json +69 -46
- package/school/paper_search_school/assets/capsule_zh-Hant.json +68 -45
- 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/config.py +11 -10
- package/school/paper_search_school/download_diagnostics.py +7 -2
- package/school/paper_search_school/engine/access_rules.py +12 -3
- package/school/paper_search_school/engine/batch.py +43 -11
- package/school/paper_search_school/engine/batch_access.py +38 -12
- 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 +38 -3
- 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 +28 -4
- package/school/paper_search_school/engine/fulltext_page.py +45 -7
- package/school/paper_search_school/engine/router.py +16 -1
- package/school/paper_search_school/entitlements.py +1 -1
- 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 +54 -5
- package/school/paper_search_school/progress_view.py +63 -43
- 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/site.py +12 -4
- package/school/paper_search_school/school_test.py +1 -1
- package/school/paper_search_school/server.py +17 -6
- 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 -99
- 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
|
@@ -29,6 +29,7 @@ unsupported_platform unsupported_publisher user_skipped user_marked_no_entitleme
|
|
|
29
29
|
article_not_yet_published doi_not_resolved doi_not_registered network_unavailable
|
|
30
30
|
institution_federation_unavailable browser_unresponsive browser_operation_timeout login_not_reached idp_no_return_to_publisher
|
|
31
31
|
generic_institution_entry_missing no_institution_entry browser_closed browser_connection_lost
|
|
32
|
+
pdf_not_offered
|
|
32
33
|
""".split())
|
|
33
34
|
_STATES = _FAILURES | _STATUSES | frozenset("""
|
|
34
35
|
started article_loaded article_loaded_after_sso pdf_response_captured
|
|
@@ -58,9 +59,9 @@ pdf_capture_started pdf_navigation_error pdf_saved pdf_state_candidate post_logi
|
|
|
58
59
|
post_login_hold_article_access post_login_hold_auth_wall post_login_hold_login_page
|
|
59
60
|
post_run_hold publisher_access_blocked publisher_content_error publisher_unreachable publisher_login_menu_opened
|
|
60
61
|
publisher_pdf_link_unverified publisher_session_save_failed publisher_session_saved
|
|
61
|
-
publisher_terms_accepted personal_account_offer_skipped personal_account_offer_left
|
|
62
|
+
publisher_terms_accepted download_terms_agreed personal_account_offer_skipped personal_account_offer_left
|
|
62
63
|
record_article_return record_article_return_error seamlessaccess_chooser_opened
|
|
63
|
-
shared_cookies_exported shared_cookies_loaded sso_entry_clicked sso_entry_error sso_start
|
|
64
|
+
shared_cookies_exported shared_cookies_loaded sso_entry_clicked sso_entry_opened sso_entry_error sso_start challenge_type
|
|
64
65
|
access_unknown_pdf_first access_unknown_pdf_failed pdf_step_login_required login_round_trip_returned
|
|
65
66
|
pdf_probe pdf_probe_captured pdf_probe_refused no_access_after_login pdf_found_while_waiting
|
|
66
67
|
login_entry_missing login_entry_controls access_menu_opened access_menu_entry_refused access_menu_error
|
|
@@ -161,6 +162,10 @@ def serialize_download_result(result, *, phase=None, full_text=None,
|
|
|
161
162
|
"final_url_role": _url_role(_get(result, "final_url")),
|
|
162
163
|
"pdf_url_role": _url_role(_get(result, "pdf_url")),
|
|
163
164
|
}
|
|
165
|
+
from .browser.challenge.kinds import LABELS as CHALLENGE_TYPES
|
|
166
|
+
challenge_type = _get(result, "challenge_type")
|
|
167
|
+
if type(challenge_type) is str and challenge_type in CHALLENGE_TYPES:
|
|
168
|
+
packet["challenge_type"] = challenge_type
|
|
164
169
|
if phase is not None:
|
|
165
170
|
packet["phase"] = _choice(phase, {"primary", "retry"}, "unknown")
|
|
166
171
|
if doi and type(artifact_name) is str and artifact_name == re.sub(r"[^\w\-.]", "_", doi) + ".pdf":
|
|
@@ -201,6 +201,12 @@ OPEN_SIGNS_JS = r"""() => {
|
|
|
201
201
|
if (/(?:^|\s)license(?:\s|$)/i.test(link.getAttribute('rel')) && CC.test(link.href) && !link.closest(NOT))
|
|
202
202
|
return `licence link: ${short(link.href)}`;
|
|
203
203
|
}
|
|
204
|
+
// A licence badge named for what it is, without rel="license": F1000's open research platforms'
|
|
205
|
+
// <a aria-label="Creative Commons License CC-BY" href="https://creativecommons.org/licenses/">
|
|
206
|
+
// (Bioethics Open Research, taken for a closed page and sent to the school's login, 2026-11-24).
|
|
207
|
+
for (const a of document.querySelectorAll('a[href][aria-label*="creative commons licen" i]')) {
|
|
208
|
+
if (CC.test(a.href) && !a.closest(NOT)) return `licence link: ${short(a.href)}`;
|
|
209
|
+
}
|
|
204
210
|
for (const script of [...document.querySelectorAll('script[type="application/ld+json"]')].slice(0, 8)) {
|
|
205
211
|
let data;
|
|
206
212
|
try { data = JSON.parse((script.textContent || '').slice(0, 200000)); } catch (_) { continue; }
|
|
@@ -270,13 +276,16 @@ _OFFER_PHRASE = re.compile(
|
|
|
270
276
|
# read this": RSC and Oxford Academic "You do not currently have access to this
|
|
271
277
|
# content/article.", ScienceDirect "<school> does not subscribe to this content
|
|
272
278
|
# on ScienceDirect.", Sage "Access via <school> is not available as they do not
|
|
273
|
-
# subscribe to Sage Journals content.".
|
|
274
|
-
#
|
|
279
|
+
# subscribe to Sage Journals content.", nature.com "Access to this article via <institution>
|
|
280
|
+
# is not available." (its name in <strong> with no spaces around it, so the line reads
|
|
281
|
+
# "via<name>is not available"; Nature Cities, Windows 2026-11-24). A whole line: help copy
|
|
282
|
+
# and conditionals around it are not a denial.
|
|
275
283
|
_DENIAL_LINE = re.compile(
|
|
276
284
|
r"(?:(?:(?P<who>you|your (?:institution|organi[sz]ation))|(?P<name>[^.!?:\"“”]{2,120}?))\s+(?:do|does)\s+not"
|
|
277
285
|
r"\s+(?:currently\s+)?(?:have access to|subscribe to)\s+(?:this|the)\s+"
|
|
278
286
|
r"(?:article|content|pdf|full text|journal|book|chapter)(?:\s+on\s+[^.!?]{2,40})?"
|
|
279
|
-
r"|access
|
|
287
|
+
r"|access (?:to this (?:article|content|chapter|book|pdf|issue)\s+)?via\s*(?P<via>[^.!?]{2,120}?)\s*is not available"
|
|
288
|
+
r"(?:\s+as they do not subscribe to [^.!?]{2,80})?"
|
|
280
289
|
r"|your (?:institution|organi[sz]ation) has not (?:subscribed to this content|purchased access to this article))\.?",
|
|
281
290
|
re.I)
|
|
282
291
|
_DENIAL_CONTEXT = re.compile(
|
|
@@ -94,6 +94,15 @@ from .batch_user import PdfFoundWhileWaiting, UserProvidedPdf, UserRequestsMixin
|
|
|
94
94
|
from ..browser import watchdog
|
|
95
95
|
from ..entitlements import UserSkippedArticle, UserStoppedBatch
|
|
96
96
|
|
|
97
|
+
# Why a school login that ended without the article ended, set by the login itself: kept as the
|
|
98
|
+
# article's reason, not "PDF not captured". DBpia's institution search had no entry for the school
|
|
99
|
+
# (institution_federation_unavailable, its wait ended so), and the article was reported as 原因不明 ·
|
|
100
|
+
# 没取到 PDF (Windows 2026-11-24).
|
|
101
|
+
_LOGIN_ENDINGS = frozenset({GENERIC_ENTRY_MISSING, NO_INSTITUTION_ENTRY, "institution_federation_unavailable",
|
|
102
|
+
"publisher_institution_entry_missing", "idp_no_return_to_publisher"})
|
|
103
|
+
# An article open to all that its site gives as a web page only (``_page_offers_no_pdf``).
|
|
104
|
+
PDF_NOT_OFFERED = "pdf_not_offered"
|
|
105
|
+
|
|
97
106
|
|
|
98
107
|
class PublisherBatchDownloader(
|
|
99
108
|
LoginMixin,
|
|
@@ -388,6 +397,8 @@ class PublisherBatchDownloader(
|
|
|
388
397
|
require_interactive_browser: bool = False,
|
|
389
398
|
) -> None:
|
|
390
399
|
self.config = load_config() if config is None else config
|
|
400
|
+
from ..browser.challenge.services.solver import Budget
|
|
401
|
+
self._captcha_budget = Budget(config=self.config)
|
|
391
402
|
self.profile = profile
|
|
392
403
|
self.institution_query = institution_query.strip()
|
|
393
404
|
self.login_timeout_sec = login_timeout_sec
|
|
@@ -447,7 +458,7 @@ class PublisherBatchDownloader(
|
|
|
447
458
|
config["browser_headless"] = False
|
|
448
459
|
started = time.time()
|
|
449
460
|
ctx = get_persistent_context(profile_path, config)
|
|
450
|
-
from ..browser.challenge.interaction import prepare_context
|
|
461
|
+
from ..browser.challenge.local.interaction import prepare_context
|
|
451
462
|
prepare_context(ctx)
|
|
452
463
|
self._browser_start = {**dict(getattr(browser_backend, "LAST_LAUNCH", {}) or {}),
|
|
453
464
|
"seconds": round(time.time() - started, 1), **({"relaunch": relaunch} if relaunch else {})}
|
|
@@ -488,6 +499,7 @@ class PublisherBatchDownloader(
|
|
|
488
499
|
self._record_title = record.title
|
|
489
500
|
self._expected_title = ""
|
|
490
501
|
self._manual_school = False
|
|
502
|
+
self._article_host = "" # the site the article opens on (_note_article_host)
|
|
491
503
|
self._track_article_for_adapter(page, record.doi)
|
|
492
504
|
from ..browser import watchdog
|
|
493
505
|
|
|
@@ -555,16 +567,24 @@ class PublisherBatchDownloader(
|
|
|
555
567
|
# reader's access showed): the school's login, once, then the PDF again.
|
|
556
568
|
# So too for a page taken as open to all whose PDF entry asked for access
|
|
557
569
|
# (PNAS 2026-11-17: a Creative Commons line in the copyright notes, "GET
|
|
558
|
-
# ACCESS" by the title, the PDF addresses 403 until the school's login)
|
|
559
|
-
|
|
560
|
-
|
|
570
|
+
# ACCESS" by the title, the PDF addresses 403 until the school's login), and
|
|
571
|
+
# for one whose PDF was sent to the article's web page: open for its web page
|
|
572
|
+
# only, or not at all (JAMA's citation_fulltext_world_readable, 10.1001/jama.2025.19316;
|
|
573
|
+
# jacc.org's "This is an Open Access Article" by "GET ACCESS", 10.1016/j.jcmg.2025.09.021;
|
|
574
|
+
# both ended as pdf_not_captured, no school tried, Windows 2026-11-23).
|
|
575
|
+
taken_as_open = getattr(result, "_taken_as_open", False)
|
|
576
|
+
sent_back = self._pdf_sent_to_article(page, result, attempts_from) if taken_as_open else []
|
|
577
|
+
gated = bool(taken_as_open and (sent_back or any(e["state"] == "pdf_entry_gated" for e in result.events)))
|
|
561
578
|
retry = (not wall and (getattr(result, "_pdf_first", False) or gated) and not self._school_login_done())
|
|
562
579
|
if wall or retry:
|
|
563
580
|
if wall:
|
|
564
581
|
self._event(result, "auth_wall_after_pdf_attempt", self._decision_text(page))
|
|
565
582
|
else:
|
|
583
|
+
url = str(getattr(page, "url", "") or "")
|
|
566
584
|
self._event(result, "open_access_pdf_gated" if gated and not getattr(result, "_pdf_first", False)
|
|
567
|
-
else "access_unknown_pdf_failed",
|
|
585
|
+
else "access_unknown_pdf_failed",
|
|
586
|
+
f"{url[:160]} | PDF sent to the article's web page: {str(sent_back[-1].get('url'))[:120]}"
|
|
587
|
+
if sent_back else url)
|
|
568
588
|
self._reopen_article_page(page, result)
|
|
569
589
|
result._pdf_retry_login = True
|
|
570
590
|
logged_in = self._complete_login_from_current_page(page, result)
|
|
@@ -622,10 +642,14 @@ class PublisherBatchDownloader(
|
|
|
622
642
|
self._write_diagnostic(page, result, run_dir)
|
|
623
643
|
return result
|
|
624
644
|
if not pdf_bytes:
|
|
625
|
-
#
|
|
626
|
-
#
|
|
627
|
-
|
|
628
|
-
|
|
645
|
+
# The login's own ending says why (_LOGIN_ENDINGS): a site whose page offered no
|
|
646
|
+
# institution entry, a school the publisher's list lacks. A wait on the user that ran
|
|
647
|
+
# out says where it ended, as for a login that did not complete (_login_failed: the
|
|
648
|
+
# bridge's login_timeout or login_not_reached): DBpia's institution search found
|
|
649
|
+
# nothing for a school, the wait stood a minute on it, then 没取到 PDF (2026-11-24).
|
|
650
|
+
result.reason = result.state = (
|
|
651
|
+
result.reason if result.reason in _LOGIN_ENDINGS
|
|
652
|
+
else "sso_required" if getattr(result, "login_wait_page", "") else "pdf_not_captured")
|
|
629
653
|
result.final_url = page.url
|
|
630
654
|
result.title = self._title(page)
|
|
631
655
|
self._write_diagnostic(page, result, run_dir)
|
|
@@ -638,9 +662,17 @@ class PublisherBatchDownloader(
|
|
|
638
662
|
self._write_diagnostic(page, result, run_dir)
|
|
639
663
|
return result
|
|
640
664
|
block_reason = self._login_block_reason(page)
|
|
641
|
-
|
|
665
|
+
# The capture came after this item's school login, or none came in this item:
|
|
666
|
+
# then the school's session on the page, from an earlier item, is what counts.
|
|
667
|
+
if (not block_reason and (signed_in or not self._school_login_done())
|
|
642
668
|
and self._pdf_sent_to_article_after_login(page, result, attempts_from)):
|
|
643
669
|
block_reason = "institution_pdf_entitlement_missing"
|
|
670
|
+
if (not block_reason and taken_as_open and len(result.pdf_attempts) == attempts_from
|
|
671
|
+
and self._page_offers_no_pdf(page)):
|
|
672
|
+
# Open to all, nothing tried, and nothing on the page names a PDF.
|
|
673
|
+
block_reason = PDF_NOT_OFFERED
|
|
674
|
+
self._event(result, PDF_NOT_OFFERED, f"{str(getattr(page, 'url', '') or '')[:160]} | "
|
|
675
|
+
f"{self._title(page)[:80]} | nothing on the page names a PDF")
|
|
644
676
|
result.reason = block_reason or "pdf_not_captured"
|
|
645
677
|
result.state = result.reason
|
|
646
678
|
result.final_url = page.url
|
|
@@ -695,7 +727,7 @@ class PublisherBatchDownloader(
|
|
|
695
727
|
except PublisherPlatformUnsupported as platform:
|
|
696
728
|
result.reason = result.state = "unsupported_platform"
|
|
697
729
|
self._event(result, "unsupported_platform", str(platform))
|
|
698
|
-
progress_reporter.update(phase=f"这篇文章只在 {platform}
|
|
730
|
+
progress_reporter.update(phase=f"这篇文章只在 {platform} 平台提供,PaperSearch 还没有这个平台的规则,当前路径已停止")
|
|
699
731
|
self._write_diagnostic(page, result, run_dir)
|
|
700
732
|
return result
|
|
701
733
|
except PublisherContentError as error:
|
|
@@ -27,7 +27,15 @@ from .batch_common import (
|
|
|
27
27
|
# not answer: Envoy, nginx and similar. Nothing else is on such a page.
|
|
28
28
|
# A publisher's own page for a blocked address: "Your IP has been blocked.", "Your IP
|
|
29
29
|
# 69.63.193.18 has been blocked." (Science, 2026-11-16), "your IP address … has been blocked".
|
|
30
|
-
|
|
30
|
+
# Taylor & Francis (2026-11-25), a page titled "Error" for the article, its PDF and its institution entry alike:
|
|
31
|
+
# "The IP address of 203.0.113.7 has not been recognised to access this page. Please contact … quoting the IP address".
|
|
32
|
+
# Not recognised, the driver took its sign-in button for the school's login and waited on the user each paper,
|
|
33
|
+
# then wrote 没权限. A web firewall's page in Chinese, under that line as the title (Sage's sage.cnpereading.com, HTTP
|
|
34
|
+
# 592, 2026-11-25: "您的访问请求可能对网站造成安全威胁,请求已被阻断"): taken for an article page without a login entry,
|
|
35
|
+
# each paper written 待适配.
|
|
36
|
+
_IP_BLOCKED = re.compile(r"\byour ip(?: address)?(?: [0-9a-f.:]+)? (?:has been|is) blocked\b"
|
|
37
|
+
r"|\bthe ip address (?:of )?[0-9a-f.:]+ has not been recogni[sz]ed to access\b"
|
|
38
|
+
r"|访问请求可能对网站造成安全威胁")
|
|
31
39
|
_GATEWAY_ERROR_MARKERS = (
|
|
32
40
|
"upstream connect error or disconnect/reset before headers",
|
|
33
41
|
"502 bad gateway", "503 service unavailable", "503 service temporarily unavailable",
|
|
@@ -171,7 +179,8 @@ class AccessMixin:
|
|
|
171
179
|
"""The publisher's own page for a blocked address, under its usual title (Science,
|
|
172
180
|
2026-11-16: "Your IP 69.63.193.18 has been blocked."): no login can open it. Read
|
|
173
181
|
from the article page's text the access check reads anyway (``_access_snapshot``)."""
|
|
174
|
-
|
|
182
|
+
# Its start, and its end: Taylor & Francis writes it after the site's whole header.
|
|
183
|
+
return bool(_IP_BLOCKED.search(" ".join((text[:4000] + "\n" + text[-2000:]).lower().split())))
|
|
175
184
|
|
|
176
185
|
def _raise_on_publisher_access_blocked(self, page: Any) -> None:
|
|
177
186
|
if self._publisher_access_blocked(page):
|
|
@@ -264,7 +273,12 @@ class AccessMixin:
|
|
|
264
273
|
def _article_access_available(self, page: Any) -> bool:
|
|
265
274
|
"""The article page no longer says the reader is signed out: the PDF
|
|
266
275
|
decides. In the login that follows a failed PDF, only the institution's
|
|
267
|
-
session or a completed login round trip count
|
|
276
|
+
session or a completed login round trip count, and on the site the adapter
|
|
277
|
+
sent the login to (``_on_login_site``) also access every reader has there
|
|
278
|
+
(``access_rules.OPEN_TO_ALL``: an open-access badge or licence): that page is
|
|
279
|
+
not the one whose PDF failed. Not "Full text access" alone: ScienceDirect
|
|
280
|
+
shows it for full text through ClinicalKey or a personal account, with no PDF
|
|
281
|
+
(J Hepatol, 2026-10-31), and the school's login there is still to be done."""
|
|
268
282
|
# A verification/error page can retain the exact article URL. Its
|
|
269
283
|
# lack of a sign-in button is not evidence of full-text access.
|
|
270
284
|
if page.is_closed() is True:
|
|
@@ -274,15 +288,26 @@ class AccessMixin:
|
|
|
274
288
|
return False
|
|
275
289
|
if self._institution_pdf_entitlement_missing(page):
|
|
276
290
|
return False
|
|
277
|
-
|
|
291
|
+
url = str(getattr(page, "url", "") or "")
|
|
292
|
+
if not self._is_success_article_url(url):
|
|
278
293
|
return False
|
|
279
|
-
verdict, basis,
|
|
294
|
+
verdict, basis, evidence = self._access_decision(page)
|
|
280
295
|
if verdict == access_rules.OUT:
|
|
281
296
|
return False
|
|
282
297
|
if basis == "session" or self._school_login_done():
|
|
283
298
|
return True
|
|
284
299
|
# The login that follows a failed PDF waits for the school's login itself.
|
|
285
|
-
|
|
300
|
+
result = getattr(self, "_item_result", None)
|
|
301
|
+
if not getattr(result, "_pdf_retry_login", False):
|
|
302
|
+
return True
|
|
303
|
+
# Its sign-in sent to this article on another site, open to every reader there:
|
|
304
|
+
# the PDF is taken there (ScienceDirect's "Open access" for jacc.org's 403, 2026-11-23).
|
|
305
|
+
if (verdict != access_rules.IN or not access_rules.OPEN_TO_ALL.search(evidence.split("badge: ", 1)[-1])
|
|
306
|
+
or not self._on_login_site(page, result)):
|
|
307
|
+
return False
|
|
308
|
+
if not any(e["state"] == "login_site_article_readable" for e in result.events):
|
|
309
|
+
self._event(result, "login_site_article_readable", f"{url[:160]} | {verdict} ({basis}): {evidence[:160]}")
|
|
310
|
+
return True
|
|
286
311
|
|
|
287
312
|
def _school_login_done(self) -> bool:
|
|
288
313
|
"""This item reached its IdP; selecting a school is only an attempt."""
|
|
@@ -311,17 +336,18 @@ class AccessMixin:
|
|
|
311
336
|
return True
|
|
312
337
|
return bool(named) and self._names_configured_school(named)
|
|
313
338
|
|
|
314
|
-
def _no_access_after_login(self, page: Any, result: DownloadResult) -> str:
|
|
315
|
-
"""Evidence that the article page, after this item's school login
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
339
|
+
def _no_access_after_login(self, page: Any, result: DownloadResult, *, session_shown: bool = False) -> str:
|
|
340
|
+
"""Evidence that the article page, after this item's school login (or with
|
|
341
|
+
the school's session shown on it, ``session_shown``: signed in by an earlier
|
|
342
|
+
item), still denies the article, shows only its abstract, offers it for sale
|
|
343
|
+
or is the site's signed-out page type; "" otherwise, and while the site's own
|
|
344
|
+
login pages remain to be opened (an Elsevier journal's site signs in on itself,
|
|
319
345
|
then on ScienceDirect) or the login site's own article remains to be tried
|
|
320
346
|
(``_return_from_login_site``). Not the "Access through <school>" gate: that
|
|
321
347
|
is a remembered school not signed in on this site."""
|
|
322
348
|
url = str(getattr(page, "url", "") or "")
|
|
323
349
|
if (not self._is_success_article_url(url) or self._is_auth_page(url)
|
|
324
|
-
or self._is_challenge_page(page) or not self._school_login_done()):
|
|
350
|
+
or self._is_challenge_page(page) or not (session_shown or self._school_login_done())):
|
|
325
351
|
return ""
|
|
326
352
|
opened = {e.get("detail") for e in result.events if e["state"] == "login_page_opened"}
|
|
327
353
|
if any(target not in opened for target in self.adapter.login_page_urls(page)):
|