Comments scraping + Substack-styled rendering + macOS driver fixes + README doc updates#46
Open
sanket-k wants to merge 4 commits into
Open
Comments scraping + Substack-styled rendering + macOS driver fixes + README doc updates#46sanket-k wants to merge 4 commits into
sanket-k wants to merge 4 commits into
Conversation
- Add --comments flag to fetch and cache each post's comment thread (public threads free; paid-only threads via --premium). Renders threads into the per-post HTML page and exposes comment_count to the index. - Add --comments-sort (best | most_recent_first). - Fix macOS driver detection: locate Chrome/Edge under /Applications and resolve correct driver platform (mac-arm64 vs mac-x64, mac64_m1). - Add driver recovery: recreate crashed sessions and periodic restarts to shed leaked state; suppress noise via quiet flag. - Add Sort by Comments to the index UI + comment section CSS. - Add backfill_comment_counts.py to repair older data files. - Expand the test suite to cover comment helpers and HTML rendering.
- Document --comments / --comments-sort and the caching/rendering model. - Add full CLI reference table covering all flags. - Correct the browser requirement (Chrome default + macOS/Apple Silicon detection) instead of the stale "Microsoft Edge" note. - Document backfill_comment_counts.py and the output directory layout. - Add mermaid diagrams: system architecture, scrape workflow sequence, driver fallback, and on-disk outputs.
Rewrite per-post HTML to the classic default Substack look: Spectral serif body (19px/1.6), orange (#ff6719) links, left-aligned text, white background, 728px column, and a centered cover/title/subtitle/byline header built from structured metadata instead of inlined markdown. - Rewrite assets/css/essay-styles.css with :root theme tokens and header rules - Align author index (assets/css/style.css, author_template.html) to palette - Add build_post_header, split_metadata_and_body, build_post_document, and render_post_to_html_file helpers in substack_scraper.py - Route scrape_posts through the structured render path; keep flat (meta=None) path intact for legacy compatibility - Add render_posts.py standalone regenerate script (no network) plus --render-only/--render-all CLI flags - Add 13 tests covering header rendering, metadata splitting, structured rendering, and end-to-end regenerate - Document rendering and new flags in README
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds three related improvements to the scraper:
1. Comment scraping (
--comments)--commentsflag fetches and caches each post's comment thread.Public threads are free; paid-only threads require
--premium.--comments-sortflag (best|most_recent_first).comment_countisexposed to the index UI (with a new "Sort by Comments" option).
backfill_comment_counts.pyto repair older data files.2. macOS driver support & reliability
/Applicationsand resolves theright driver platform (
mac-arm64vsmac-x64,mac64_m1).to shed leaked state; suppresses noise via the quiet flag.
3. Substack-styled HTML rendering
body (19px/1.6), orange (#ff6719) links, left-aligned text, 728px column,
and a centered cover/title/subtitle/byline header built from structured
metadata rather than inlined markdown.
render_posts.pystandalone regenerate script (no network required).--render-only/--render-allCLI flags.4.
README.md— major overhaul :Usage examples for comments & sorting,
Browser & Driver Support, Backfilling Comment Counts,
Files in Browser.
Changes
substack_scraper.py— comment helpers, structured render path, driver fixesrender_posts.py— new network-free regenerate scriptbackfill_comment_counts.py— new data repair utilityassets/css/essay-styles.css,assets/css/style.css,author_template.html— restyledassets/js/populate-essays.js— "Sort by Comments" + comment_count handlingtests/test_substack_scraper.py— 13+ new tests (comments, rendering, regenerate)README.md— CLI reference table, architecture/workflow mermaid diagramsTesting
pytest tests/Backward compatibility
The structured render path falls back to the flat (
meta=None) path for legacycompatibility, so existing data files keep working.