Quivara commited on
Commit
1ae0901
·
verified ·
1 Parent(s): 6029d2a

Update alisto_project/backend/ingest_reddit.py

Browse files
alisto_project/backend/ingest_reddit.py CHANGED
@@ -390,28 +390,27 @@ def is_credible_user(post):
390
  # orchestrates the entire scraping process (historical scan + real-time stream)
391
  async def scrape_reddit():
392
  print("Connecting to Reddit API...")
393
-
394
- client_id = os.getenv("REDDIT_CLIENT_ID")
395
- client_secret = os.getenv("REDDIT_CLIENT_SECRET")
396
 
397
  if not client_id or not client_secret:
398
  print("❌ Error: Client ID or Secret missing in .env")
399
  return
400
 
401
  reddit = asyncpraw.Reddit(
402
- client_id=client_id,
403
- client_secret=client_secret,
404
- user_agent=os.getenv("REDDIT_USER_AGENT", "script:alisto_bot:v3.0")
405
- )
 
 
406
 
407
  try:
408
  subreddit = await reddit.subreddit(SUBREDDITS)
409
  print(f"👁️  ALISTO ACTIVE: Monitoring r/{SUBREDDITS}...")
410
 
411
  # --- PHASE 1: FETCH LATEST EXISTING POSTS (e.g., last 500) ---
412
- print("🔍 Scanning last 500 posts for missed alerts...")
413
- # iterates over the last 500 posts asynchronously
414
- async for post in subreddit.new(limit=10):
415
  await process_post(post)
416
 
417
  print("✅ Historical scan complete")
 
390
  # orchestrates the entire scraping process (historical scan + real-time stream)
391
  async def scrape_reddit():
392
  print("Connecting to Reddit API...")
 
 
 
393
 
394
  if not client_id or not client_secret:
395
  print("❌ Error: Client ID or Secret missing in .env")
396
  return
397
 
398
  reddit = asyncpraw.Reddit(
399
+ client_id=os.getenv("REDDIT_CLIENT_ID"),
400
+ client_secret=os.getenv("REDDIT_CLIENT_SECRET"),
401
+ user_agent=os.getenv("REDDIT_USER_AGENT"),
402
+ username=os.getenv("REDDIT_USERNAME"),
403
+ password=os.getenv("REDDIT_PASSWORD")
404
+ )
405
 
406
  try:
407
  subreddit = await reddit.subreddit(SUBREDDITS)
408
  print(f"👁️  ALISTO ACTIVE: Monitoring r/{SUBREDDITS}...")
409
 
410
  # --- PHASE 1: FETCH LATEST EXISTING POSTS (e.g., last 500) ---
411
+ print("🔍 Scanning last 5 posts for missed alerts...")
412
+ # iterates over the last 5 posts asynchronously
413
+ async for post in subreddit.new(limit=5):
414
  await process_post(post)
415
 
416
  print("✅ Historical scan complete")