r/redditdev • u/bbb23sucks • 3d ago
PRAW Creating a Moderator Discussion in Modmail via PRAW renders your account unable to be logged into, even after resetting the password.
Title
r/redditdev • u/AdNeither9103 • 6d ago
PRAW Fetching more than 1000 posts in batches using PRAW
Hi all, I am working on a project where I'd pull a bunch of posts every day. I don't anticipate needing to pull more than 1000 posts per individual requests, but I could see myself fetching more than 1000 posts in a day spanning multiple requests. I'm using PRAW, and these would be strictly read requests. Additionally, since my interest is primary data collection and analysis, are there alternatives that are better suited for read only applications like pushshift was? Really trying to avoid web scraping if possible.
TLDR: Is the 1000 post fetch limit for PRAW strictly per request, or does it also have a temporal aspect?
r/redditdev • u/Oussama_Gourari • Jun 18 '24
PRAW Anyone getting prawcore.exceptions.Redirect?
Suddenly I am starting to get prawcore.exceptions.Redirect
:
DEBUG:prawcore:Fetching: GET https://oauth.reddit.com/r/test/new at 1718731272.9929357
DEBUG:prawcore:Data: None
DEBUG:prawcore:Params: {'before': None, 'limit': 100, 'raw_json': 1}
DEBUG:prawcore:Response: 302 (0 bytes) (rst-None:rem-None:used-None ratelimit) at 1718731273.0669003
prawcore.exceptions.Redirect: Redirect to /
Anyone having same issue?
r/redditdev • u/Moamr96 • Nov 23 '24
PRAW praw not listing comments
so with the recent changes, power delete suit misses many old things, so I updated praw to 7.8.1 on python and it seems user.comments.new(limit=None)
doesn't actually see them.
I'm guessing it will take some time for reddit to pass this to praw?
Edit: just tried reddit api, it also doesn't show them lol neither for comments or submitted
edit for reference this is what I'm talking about
r/redditdev • u/PKtheworldisaplace • 3d ago
PRAW Is there no way to pull a full year of posts for a given subreddit?
I tried this using PRAW and it only pulled about a week and a half of posts--I assume because it hit the 1000 post-limit.
It sounds like there used to be a way using Pushshift, but that is only for reddit mods.
So is this now simply impossible?
r/redditdev • u/UltFireSword • Dec 08 '24
PRAW Bot gets shadowbanned instantly, then permabanned
Not sure if I’m doing anything wrong, but I have a really simple bot that checks a University subreddit for course titles, and responds with the course link to the university course catalog.
I registered the account for an app on the reddit’s api page, got the moderator to add the account to approved posters, and don’t spam at all (1/2 comments per hour). After commenting even once, the bot gets shadowbanned, then after spam appealing every day for 3 months, it gets perma banned.
Is this because of the course links? Is there a way around this?
r/redditdev • u/0liveeee • 29d ago
PRAW Best Subreddits for Scraping for AI
Hello, I am trying to train an AI model, specifically for understanding with emojis and I was wondering if anyone could list off a couple subreddits that I can take posts and/or comments from to train my model. I am looking for texts that will contain emojis, preferably not a single emoji at a time, but multiple emojis in a set.
Thank you for any help you can provide or if there's any advice!
r/redditdev • u/Relevant_Ad_5063 • Nov 15 '24
PRAW How to Give Awards Using Reddit API: Getting Latest gild_ids and Alternatives to PRAW?
I’m working on a project where I need to programmatically give awards to submissions and comments using the Reddit API. I’m using PRAW 7.7.1, but I’ve run into some issues:
Outdated gild_ids: When using Submission.award() or Comment.award(), we need to specify the gild_id
to indicate the type of award. However, it seems that PRAW’s current documentation doesn’t support the latest award types available on Reddit. This makes it challenging to give newer awards.
My specific questions are:
- How can I obtain the gild_ids of the latest award types?
- Is there an updated list or a method to retrieve them dynamically?
- Are there any workarounds within PRAW to access newer awards?
- Is there a way to give awards using the Reddit API without PRAW?
- Can I make direct API calls to handle awards?
- Are there alternative libraries or methods that support the latest award types?
Any insights, code examples, or pointers to relevant documentation would be greatly appreciated.
r/redditdev • u/Ok-Community123 • 29d ago
PRAW Issues accessing praw.ini file in airflow run on docker
I'm using the praw library in a Python script, and it works perfectly when run locally. However, I'm facing issues when trying to run the script inside an Airflow DAG in Docker.
The script relies on a praw.ini file to store credentials (client_id, client_secret, username, and password). Although the praw.ini file is stored in the shared Docker volume and has the correct read permissions, I encounter the following error when running it in Docker:
MissingRequiredAttributeException: Required configuration setting 'client_id' missing.
Interestingly, if I modify the script to load credentials from a .env file instead of praw.ini, it runs successfully on Airflow in Docker.
Has anyone else experienced issues with parsing .ini files in Airflow DAGs running in Docker? Am I missing something here?
Please excuse me if I missing something basic here since this is my first time working on Airflow and Docker.
r/redditdev • u/MustaKotka • Oct 25 '24
PRAW Submission maximum number and subreddit.new(limit=####)
It seems that the maximum number of submissions I can fetch is 1000:
limit
– The number of content entries to fetch. If limit isNone
, then fetch as many entries as possible. Most of Reddit’s listings contain a maximum of 1000 items, and are returned 100 at a time. This class will automatically issue all necessary requests (default: 100).
Can anyone shed some more light on this limit? What happens with None? If I'm using .new(limit=None)
how many submissions am I actually getting at most? Also; how many API requests am I making? Just whatever number I type in divided by 100?
Use case: I want the URLs of as many submissions as possible. These URLs are then passed through random.choice(URLs)
to get a singular random submission link from the subreddit.
Actual code. Get submission titles (image submissions):
def get_image_links(reddit: praw.Reddit) -> list:
sub = reddit.subreddit('example')
image_candidates = []
for image_submission in sub.new(limit=None):
if (re.search('(i.redd.it|i.imgur.com)', image_submission.url):
image_candidates.append(image_submissions.url)
return image_candidates
These image links are then saved to a variable which is then later passed onto the function that generates the bot's actual functionality (a comment reply):
def generate_reply_text(image_links: list) -> str:
...
bot_reply_text += f'''[{link_text}]({random.choice(image_links)})'''
...
r/redditdev • u/Anony-mouse420 • Dec 06 '24
PRAW How to Resolve /s/ Shortlinks using Praw
At the moment, I'm using requests and bs4 to resolve reddit's /s/ links to expanded form. Would it be possible to do so using praw? Many thanks!
r/redditdev • u/MustaKotka • Nov 07 '24
PRAW How to fetch the number of reports on a submission?
I'm constructing a mod bot and I'd like to know the number of reports a submission has received. I couldn't find this in the docs - does this feature exist?
Or should I build my own database that stores the incoming reported submission IDs from the mod stream?
r/redditdev • u/HorrorMakesUsHappy • Nov 04 '24
PRAW How do I use logging to troubleshoot rate limiting?
Below is the output of the last three iterations of the loop. It looks like I'm being given 1000 requests, then being stopped. I'm logged in and print(reddit.user.me())
prints my username. From what I read, if I'm logged in then PRAW is supposed to do whatever it needs to do to avoid the rate limiting for me, so why is this happening?
competitiveedh
Fetching: GET https://oauth.reddit.com/r/competitiveedh/about/ at 1730683196.4189775
Data: None
Params: {'raw_json': 1}
Response: 200 (3442 bytes) (rst-3:rem-4.0:used-996 ratelimit) at 1730683196.56501
cEDH
Fetching: GET https://oauth.reddit.com/r/competitiveedh/hot at 1730683196.5660112
Data: None
Params: {'limit': 2, 'raw_json': 1}
Sleeping: 0.60 seconds prior to call
Response: 200 (3727 bytes) (rst-2:rem-3.0:used-997 ratelimit) at 1730683197.4732685
trucksim
Fetching: GET https://oauth.reddit.com/r/trucksim/about/ at 1730683197.4742687
Data: None
Params: {'raw_json': 1}
Sleeping: 0.20 seconds prior to call
Response: 200 (2517 bytes) (rst-2:rem-2.0:used-998 ratelimit) at 1730683197.887361
TruckSim
Fetching: GET https://oauth.reddit.com/r/trucksim/hot at 1730683197.8883615
Data: None
Params: {'limit': 2, 'raw_json': 1}
Sleeping: 0.80 seconds prior to call
Response: 200 (4683 bytes) (rst-1:rem-1.0:used-999 ratelimit) at 1730683198.929595
battletech
Fetching: GET https://oauth.reddit.com/r/battletech/about/ at 1730683198.9305944
Data: None
Params: {'raw_json': 1}
Sleeping: 0.40 seconds prior to call
Response: 200 (3288 bytes) (rst-0:rem-0.0:used-1000 ratelimit) at 1730683199.5147257
Home of the BattleTech fan community
Fetching: GET https://oauth.reddit.com/r/battletech/hot at 1730683199.5157266
Data: None
Params: {'limit': 2, 'raw_json': 1}
Response: 429 (0 bytes) (rst-0:rem-0.0:used-1000 ratelimit) at 1730683199.5897427
Traceback (most recent call last):
This is where I received 429 HTTP response.
r/redditdev • u/Pademel0n • Nov 19 '24
PRAW Get historical comments with PRAW
Hi so I want to retrieve every single comment from a sub, however it's only giving me, in my case, 970 comments which is about 5 months of comments from the specified sub. Relevant code provided below.
#relevant prerequisites for working code...
subreddit = reddit.subreddit(subreddit_name)
comments = subreddit.comments(limit=None) #None retrieves as many as possible
for comment in comments:
#relevant processing and saving
r/redditdev • u/BubblyGuitar6377 • Oct 09 '24
PRAW how to get video or image from a post
i am new to praw in the documentation their is no specific mention of image or video (i have read first few pages )
r/redditdev • u/RobertD3277 • 22d ago
PRAW Unusual log-in problem
I have a bot that I have been building and it works perfect with my personal account.
EDIT: I am verified the phone number on the secondary account and have made sure that two-factor authentication is turned off.
I created an account strictly for the bot and have verified the credentials multiple times, but every time I try to run the API through pro, it tells me that I have an invalid grant error or a 401 error.
I have double checked the credentials for both the bot itself any application setup and the username that will be used with the bot. I can log into the account on multiple devices with the username and password and the bot does work with my personal identity so I know that the bot ID and the bot secret are correct.
The new account is only a few hours old. Is that the problem that is causing me not to be allowed to connect to Reddit?
I've tried strictly posting to my own personal channel on what will be the bot account and it's not even allowing me to do that.
Any feedback is greatly appreciated.
EDIT: I do not have two-factor authentication turned on as the account in question will be used strictly by the bot itself.
EDIT2: I have definitely confirmed that it is something with the account itself. I don't understand it because it's a brand new account and only been used strictly with my intentions. I have confirmed that I can log into the account manually and I can post manually with my new account. I cannot, however, use the API at all even though everything is correct.
Thank you.
r/redditdev • u/Gulliveig • Nov 20 '24
PRAW Why do I get this deprecation warning on post.edit(post_text)
My house bot active just in my sub created a sticky, which it updates all now and then using
post.edit(post_text)
On executing that statement, the bot gets the reply:
[script_name:line no.:] DeprecationWarning: Reddit will
check for validation on all posts around May-June 2020.
It is recommended to check for validation by setting
reddit.validate_on_submit to True.
post.edit(post_text)
What does this even mean?
And where/when/at what point should I place reddit.validate_on_submit = True
? On each new submission/edit? From anybody or just the bot?
The post in question is 2 days "old". The first post in my sub was on 2020-07-22, do I even need to do anything given the date range they mention?
---
Edit: on including a global
reddit.validate_on_submit = True
just after login, the warning disappeared. Was it always there and I just didn't notice? No idea. To me it came out of the blue.
r/redditdev • u/OliverB199 • Dec 05 '24
PRAW I want to scrape the most recent 1000 comments of a subreddit
How do I do this? With PRAW? Or aPRAW?
r/redditdev • u/-Samg381- • Nov 15 '24
PRAW VSCode / PRAW - Intellisense not working.
Is anyone using VSCode for PRAW development?
Intellisense does not seem to be fully functioning, and is missing a lot of praw contexts.
I have tried every suggestion I have been able to find online- I have tried switching to the Jedi interpreter in settings.json, using different vscode plugins for python- nothing.
Any help would be appreciated.
r/redditdev • u/Lex_An • Nov 06 '24
PRAW How to get all subreddit post/submission data for the past 10 years
Hi, I am trying to scrape posts from a specific subreddit for the past 10 years. So, I am using PRAW and doing something like
for submission in reddit.subreddit(subreddit_name).new(limit=None):
But this only returns me the most recent 800+ posts and it stops. I think this might be because of a limit or pagination issue, so I try something that I find on the web:
submissions = reddit.subreddit(subreddit_name).new(limit=500, params={'before': last_submission_id})
where I perform custom pagination. This doesn't work at all!
May I get suggestion on what other API/tools to try, where to look for relevant documentation, or what is wrong with my syntax! Thanks
P/S: I don't have access to Pushshift as I am not a mod of the subreddit.
r/redditdev • u/ArachnidInner2910 • Nov 13 '24
PRAW View previous comment in a thread
I'm creating a script to run off of mentions, how can I see the previous comment above in the thread to the one my bot has been mentioned in?
r/redditdev • u/hafez_verde • Oct 16 '24
PRAW PRAW but for js
Really don’t want to maintain a python environment in my otherwise purely typescript app. Anyone out there building the PRAW equivalent for nodejs? Jraw and everything else all seem dated well-beyond the recent Reddit API crackdown.
r/redditdev • u/LaraStardust • Oct 28 '24
PRAW How does Request to post on Reddit translate into the api
Hi everyone,
So a user of my product noticed they could not post in this sub: https://www.reddit.com/r/TechHelping/
the new post throws a 403, and when looking at the website, this is because there is a request permission to post?
I've never seen this before, so how does this translate into the api and such?
r/redditdev • u/DinoHawaii2021 • Oct 09 '24
PRAW What is wrong with my reddit bots code?
I added a fix to prevent my bot from spamming good human replies to the same user on a single post but my commands other than good bot broke mysteriously (I do not know why). The loop only runs when a user says good bot so I do not think it is the loop, and it should not even be able to run since the else if for good bot is not even activated by then. Does anyone know where I went wrong here?
Here is my commands function:
def commands():
try:
for item in reddit.inbox.stream(skip_existing=True):
# Check if the message is a mention and the author is authorized
if "u/i-bot9000" in item.body and item.author != "i-bot9000":
if "!count" in item.body:
threading.Thread(target=count_letters, args=(item,)).start()
elif "!help" in item.body:
reply = f"""
u/{item.author}, here is the current list of commands:
1. **!count <term> <letter>**
- *Description:* Counts the occurrences of the specified letter in the provided term.
2. **!randomletter**
- *Description:* Get a surprise! This command returns a random letter from the alphabet.
3. **!ping**
- *Description:* Pings the bot (replies with "pong").
4. **!help**
- *Description:* Feeling lost? Use this command to get this helpful message.
*Updates:* No updates to commands yet {command_mark}
"""
item.reply(reply)
print(f"{item.author} executed a command n ------------ n Command: {item.body} n n Replied: {reply} n ------------",flush=True)
elif "!randomletter" in item.body:
letters = list("abcdefghijklmnopqrstuvwxyz".upper())
reply = f"u/{item.author} You got the letter {random.choice(letters)} {command_mark}"
item.reply(reply)
print(f"{item.author} executed a command n ------------ n Command: {item.body} n n Replied: {reply} n ------------",flush=True)
elif "!ping" in item.body:
reply = f"u/{item.author} Pong! {command_mark}"
item.reply(reply)
print(f"{item.author} executed a command n ------------ n Command: {item.body} n n Replied: {reply} n ------------",flush=True)
elif item.body.lower() == "good bot" or item.body.lower() == "hood bot":
#New Anti Spam feature
confirm_reply = True
item.submission.comments.replace_more(limit=None)
for comment in item.submission.comments.list():
if comment.author == "i-bot9000" and "good human" in comment.body.lower() or "hood bot" in comment.body.lower():
if comment.parent().author == item.author:
confirm_reply = False
break
if confirm_reply:
reply = f"Good Human! {command_mark}"
item.reply(reply)
print(f"{item.author} said 'good bot' n ------------ n Comment: {item.body} n n Replied: {reply} n ------------")
except Exception as e:
print(e,flush=True)
threading.Thread(target=commands).start()
r/redditdev • u/GarlicGuitar • Aug 27 '24
PRAW How do you filter out posts based on whether they have a certain flair? (PRAW)
Is that even possible ?