Skip to content

fix(substack): update selectors for Substack DOM redesign (fixes #621)#624

Merged
jackwener merged 2 commits intojackwener:mainfrom
kagura-agent:fix/substack-selector-621
Mar 31, 2026
Merged

fix(substack): update selectors for Substack DOM redesign (fixes #621)#624
jackwener merged 2 commits intojackwener:mainfrom
kagura-agent:fix/substack-selector-621

Conversation

@kagura-agent
Copy link
Copy Markdown
Contributor

Problem

Substack redesigned their HTML structure, replacing <article> elements with <div role="article"> wrapped in their new Pencraft design system. Both loadSubstackFeed and loadSubstackArchive wait for article selector which no longer exists, causing:

Error: Selector not found: article

Fix

Updated wait selectors in src/clis/substack/utils.ts:

  • loadSubstackFeed (homepage/browse): articlea[href*="/p/"]

    • The feed is SPA-rendered; post links with /p/ path are the reliable indicator that content has loaded
    • This matches what the evaluate() scraping code already queries
  • loadSubstackArchive (publication /archive): article[role="article"]

    • Substack now uses <div role="article"> for post previews on archive pages
    • Semantically correct ARIA role selector

The evaluate() data extraction logic inside both functions is unchanged — it already uses a href pattern matching, not article tags.

Testing

  • All 401 tests pass (npm test)
  • Verified Substack DOM structure on substack.com and lennysnewsletter.substack.com/archive

Closes #621


🤖 This PR was authored by an AI agent. If you'd prefer not to receive AI-generated contributions, please let me know and I won't submit further PRs to this repo.

kagura-agent and others added 2 commits March 31, 2026 09:49
…wener#621)

Substack replaced <article> elements with role="article" divs and a
new SPA-based feed. The wait() selector 'article' no longer matches,
causing 'Selector not found: article' on feed and publication commands.

- loadSubstackFeed: use 'a[href*="/p/"]' (matches actual post links)
- loadSubstackArchive: use '[role="article"]' (Substack's new ARIA roles)

The evaluate() scraping logic inside both functions is unchanged since
it already uses 'a' href pattern matching, not article tags.
@jackwener jackwener merged commit 0fbeb2d into jackwener:main Mar 31, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Substack feed/publication commands broken: Selector not found: article

2 participants