Home > Back-end >  'ListingGenerator' object has no attribute 'top' python praw
'ListingGenerator' object has no attribute 'top' python praw

Time:07-09

I would like to filter the posts on (weekly top posts) time but my computer says the 'ListingGenerator' object has no attribute 'top'. What am I doing wrong?

import praw

reddit = praw.Reddit(
client_id = "",
client_secret = "",
user_agent = "",
username = "",
password = ""
)

subreddit = reddit.subreddit("unexpected").top(time_filter="week")

top_subreddit = subreddit.top(limit = 25)

for submission in top_subreddit:

print(submission.url)

CodePudding user response:

I believe you can use the filters of time_filter and limit together as shown below, I have tested it and it works, make sure to upvote if this helps


import praw

reddit = praw.Reddit(
    client_id="enter your client id here",
    client_secret="enter your client secret here",
    user_agent="0",
)

for submission in reddit.subreddit("Unexpected").top(time_filter="week", limit= 10):
    print(submission.title)

CodePudding user response:

figured it out allready

 top_subreddit = subreddit.top(time_filter="week",limit = 3)
  • Related