tags with class containing "title" that are near the permalink
# Better: find Title
patterns
titles = re.findall(r'\s*]*>(.*?)', content, re.DOTALL)
title_hrefs = re.findall(r'
\s*]*href="([^"]*)"', content)
print(f" titles: {len(titles)}, hrefs: {len(title_hrefs)}")
for i, p in enumerate(permalinks):
if i < len(timestamps):
ts = int(timestamps[i])
if ts >= CUTOFF_MS:
post = {
'permalink': p,
'source': source,
'timestamp': ts,
'score': int(scores[i]) if i < len(scores) else 0,
'comments': int(comments[i]) if i < len(comments) else 0,
'author': authors[i] if i < len(authors) else 'unknown',
}
# Find matching title
for j, href in enumerate(title_hrefs):
if p in href or href.endswith(p.rstrip('/')):
if j < len(titles):
post['title'] = titles[j].strip()
break
if 'title' not in post:
post['title'] = 'Unknown Title'
all_posts[p] = post
# Deduplicate by permalink (keep highest score version)
print(f"\nTotal posts in last 72h: {len(all_posts)}")
# Sort by score descending
sorted_posts = sorted(all_posts.values(), key=lambda x: x['score'], reverse=True)
# Print summary
for i, p in enumerate(sorted_posts):
dt = datetime.fromtimestamp(p['timestamp']/1000, tz=timezone.utc)
age = (datetime.now(timezone.utc) - dt).total_seconds() / 3600
print(f"{i+1}. [{p['source'].upper()}] Score:{p['score']} Comments:{p['comments']} Age:{age:.0f}h")
print(f" Title: {p['title'][:100]}")
print(f" Author: u/{p['author']}")
print(f" Link: https://old.reddit.com{p['permalink']}")
print()