Sami2000 commited on
Commit
536ee73
·
verified ·
1 Parent(s): 6fa6d32

Update reddit_search.py

Browse files
Files changed (1) hide show
  1. reddit_search.py +2 -3
reddit_search.py CHANGED
@@ -1,9 +1,8 @@
1
- ```python
2
  import os
3
  from dotenv import load_dotenv
4
  import praw
5
 
6
- # Load Reddit API credentials
7
  load_dotenv()
8
 
9
  REDDIT_CLIENT_ID = os.getenv("REDDIT_CLIENT_ID")
@@ -41,6 +40,7 @@ def search_reddit(keywords, subreddit=None, limit=20):
41
  if subreddit and subreddit.strip():
42
  for sr in subreddit.split(","):
43
  s = sr.strip()
 
44
  if s.lower().startswith("r/"):
45
  s = s[2:]
46
  if s.lower().startswith("/r/"):
@@ -69,4 +69,3 @@ def search_reddit(keywords, subreddit=None, limit=20):
69
 
70
  print(f"Total results found: {len(results)}")
71
  return results
72
- ```
 
 
1
  import os
2
  from dotenv import load_dotenv
3
  import praw
4
 
5
+ # Load Reddit API credentials from environment
6
  load_dotenv()
7
 
8
  REDDIT_CLIENT_ID = os.getenv("REDDIT_CLIENT_ID")
 
40
  if subreddit and subreddit.strip():
41
  for sr in subreddit.split(","):
42
  s = sr.strip()
43
+ # strip optional r/ prefix
44
  if s.lower().startswith("r/"):
45
  s = s[2:]
46
  if s.lower().startswith("/r/"):
 
69
 
70
  print(f"Total results found: {len(results)}")
71
  return results