Skip to content

Commit c138b87

Browse files
committed
store ISO format date in posts.json
1 parent 8d24a80 commit c138b87

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/substack2markdown/substack_scraper.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -381,11 +381,10 @@ def extract_post_data_from_preloads(self, post_preloads):
381381

382382
like_count = post_preloads["post"]["reactions"]["❤"]
383383

384-
# TODO expose date format
385-
datetime_format = "%b %d, %Y" # "Oct 01, 2025"
386-
387384
date = post_preloads["post"]["post_date"] # date in ISO format: "2025-10-01T14:43:48.389Z"
388-
date = datetime.strptime(date, "%Y-%m-%dT%H:%M:%S.%fZ").strftime(datetime_format)
385+
386+
# datetime_format = "%b %d, %Y" # "Oct 01, 2025"
387+
# date = datetime.strptime(date, "%Y-%m-%dT%H:%M:%S.%fZ").strftime(datetime_format)
389388

390389
content_html = post_preloads["post"]["body_html"]
391390
md = self.html_to_md(content_html)
@@ -599,6 +598,7 @@ async def scrape_posts(self, num_posts_to_scrape: int = 0) -> None:
599598
continue
600599
title, subtitle, like_count, date, md = self.extract_post_data(soup)
601600
post_preloads = await self.get_window_preloads(soup)
601+
date = post_preloads["post"]["post_date"] # date in ISO format: "2025-10-01T14:43:48.389Z"
602602

603603
if True:
604604
post_id = post_preloads["post"]["id"]

0 commit comments

Comments
 (0)