Skip to content

Key publisher rewrites and page actions on the page URL/content, not the caller's journal folder name #70

Closed

Description

@jdkent

journal does two jobs in Scraper: it is the storage folder (html/<journal>/<pmid>.html) and the key for journal-specific behaviour in check_for_substitute_url and get_html. ns-pond-ingestion-workflow calls process_article(pmid, "IngestionWorkflow", ...), so no journal-name rule ever fires there. ACE's own retrieve_articles(journal=None) passes efetch's Journal/Title, which often doesn't match the hard-coded names either ("The European journal of neuroscience", "The Journal of neuroscience : the official journal of the Society for Neuroscience").

What we measured

These numbers are from ns-pond's catalog: 18,770 pages scraped under IngestionWorkflow, plus 2,025 stored under real journal names.

  • Wiley abstract→full (L686) and the relatedArticles wait (L433) do nothing on current URLs. LinkOut gives doi.org/<doi>, which lands on onlinelibrary.wiley.com/doi/<doi>, and that page is already full text: HBM 56/57, EJN 29/30, and 95/100 of other sampled Wiley journals.
  • JoCN doi/abs→doi/full (L690): current direct.mit.edu URLs contain no doi/abs.
  • Frontiers (L692): 'xml\/nlm' is not a raw string, so the rewrite produces a literal backslash, and that URL returns 404. .../xml/nlm itself still returns 200 text/xml.
  • PLoS (L678): keyed on a 7-name map that misses newer titles. In browser mode the manuscript URL is served as an attachment, so Chrome downloads it and ACE saves an empty page (found while reviewing Never open PubMed web pages; open no-LinkOut PLoS articles at doi.org from the keyed esummary DOI (ace-no-pubmed-page) #69).
  • J Neurosci table clicks (L462): apart from the name key, html is read at L449, before the clicks, and that copy is what L498 returns. Clicked tables never reach the result. The ScienceDirect and Wiley waits at L476-L488 have the same problem: they wait, but the HTML was already read. HighWire's T<n>.expansion.html fallback at extract time gets a Cloudflare 403.
    • ACE extracts of 2,991 J Neurosci pages found tables in 26.
    • 2,818 J Neurosci articles have ACE as their only text and no table from any source.
    • In a sample of 1,500 current pages, 3.6% have uncaptured .table-expand-inline tables (AJNR, J Nucl Med, BMJ Case Rep, J Neurosci). A name rule would never cover most of those.

Text lost because the rules don't fire: about none. Only 182 of the 18,770 pages are from the affected journals, and 161 of them are full text anyway. PMC already covers PLOS and almost all of Frontiers. The real loss is tables, and fixing the journal name alone wouldn't recover them, because of the read-before-click bug above.

Proposed change

  1. Remove journal from check_for_substitute_url, get_html and get_html_by_pmid, and keep it only as the storage folder. Key every rule on the page's own final URL or content.
  2. Delete the Wiley and JoCN rewrites and the Wiley relatedArticles wait (no-ops on current sites).
  3. Key PLoS on the journals.plos.org URL, taking the site slug and DOI from the URL path, and drop PLOS_JOURNAL_SITES. If the XML is still wanted in browser mode, it can't come from an attachment download.
  4. Key Frontiers on the frontiersin.org URL, with replacement r'/xml/nlm'.
  5. Click .table-expand-inline whenever the page has it, whatever the journal, and read page_source after the clicks and waits.
  6. Tests: VCR cassettes of one current page per rule (Frontiers XML, a HighWire page with a collapsed table), each asserting the saved HTML contains the table.

Also in these lines: L422 starts a second Driver without quitting the first (one leaked Chrome per Springer/ScienceDirect rewrite, plausibly), and the retry loop at L458 reloads url, not new_url.

Downstream (ns-pond), the J Neurosci and other collapsed-table pages need their ACE downloads refreshed after this change for the tables to show up. No change is needed in ns-pond itself: passing a real journal name would move the cache folder, comes in several spellings per journal, and would switch on the PLoS rewrite.

Opened by Claude Code on the user's behalf.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions