add metadata for .mdx, and add explicit wait to reduce chances of not scraping anything on long substack posts#42
Open
angelotc wants to merge 1 commit intotimf34:mainfrom
Open
Conversation
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
title,subtitle,date,author,image) at the top of every scraped.mdso the files can drop straight into an MDX-based site. Replaces the previous# title/**date**/**Likes:** Nheader block.author,datePublished(ISOYYYY-MM-DD), and cover image from the page'sld+json— morereliable than the old
div.meta-EgzBVAlookup and avoids the stray"Date not found"frontmatter.scraper silently wrote a file with
title: "Untitled",date: "Date not found", and an empty body —and the
os.path.existscache check meant reruns never retried it.What changed in
substack_scraper.pycombine_metadata_and_contentnow writes YAML frontmatter; escapes embedded quotes intitle/subtitle/author.
extract_post_datanow takes aurland, on extraction failure (missing title or emptydiv.available-content), prints a[EXTRACT FAIL]diagnostic and dumps the raw page HTML todata/_debug/<writer>/<slug>.htmlfor inspection.scrape_postsskips writing the.md/.htmlwhen extraction fails, so reruns keep retryinginstead of caching a broken file.
PremiumSubstackScraper.get_url_soup:sleep(2)with aWebDriverWait(..., 20)that returns as soon asdiv.available-content,h1.post-title,h2.paywall-title, or a rate-limit<pre>appears. Timeoutlogs a warning instead of crashing.
h2.paywall-titleand returnsNone(mirroring the free scraper), so inaccessiblepremium posts are cleanly skipped instead of producing empty files.
Example frontmatter