r/learnpython • u/Flutter_ExoPlanet • Jun 14 '23
Has anyone figured a code to download a whole subreddit? (at least comments and images) yet?
Since every subreddit is going dark as a protest, I am afraid of losing some valuable content that I need to check in the future, and I can't wait till the subs goes back as they might not come back.
Has anyone been able to make a successful code to download the content of a subreddit?
I would much appreciate it. THanks
16
u/jimtk IdontChat Jun 14 '23
Easy, but it will cost you 1 million dollars! (with little finger over the lips)
0
u/Flutter_ExoPlanet Jun 14 '23
with the new API prices how much a subreddit with 50K users could cost to download?
9
Jun 15 '23
depends on how many posts there are. That said, who ta fuck is gonna want just a mass of subreddit posts. Reddit search bad enough, anything you randomly cook up is probably worse
7
Jun 14 '23
1
5
2
u/NPC_existing Jun 14 '23
I was thinking that. Same question popped up when I was thinking of how to get stock exchange data for my fintech app.
2
u/Taichou_NJx Jun 14 '23
Can you use yfinance in python or tidyquant in R is pretty good for stock/economic data
2
u/NPC_existing Jun 15 '23
yfinance had its own problems , yahooquery would of been better. In the end I chose to use Binance websocket API to get my data for crypto instead.
0
u/of_patrol_bot Jun 15 '23
Hello, it looks like you've made a mistake.
It's supposed to be could've, should've, would've (short for could have, would have, should have), never could of, would of, should of.
Or you misspelled something, I ain't checking everything.
Beep boop - yes, I am a bot, don't botcriminate me.
-3
u/Flutter_ExoPlanet Jun 14 '23
Thanks a lot, so IT HAS to be through API?
if Yes, I need to do this BEFORE the new API prices are updated then I suppose4
u/RajjSinghh Jun 14 '23
Yes. I'm no expert on the Reddit API in particular but if you automate downloading every post from a subreddit, you'll need to request each post over the API and write it out to a file, then write some reader so the post looks presentable and not just JSON body. You'll also need space to store posts in json files if you want them permanently.
Look into web scraping. In python, look at requests and beautifulsoup.
2
u/Dan6erbond2 Jun 14 '23
Reddit's API doesn't go more than 1000 items back AFAIK so it's basically useless.
1
u/Flutter_ExoPlanet Jun 16 '23
How to bypass that?
1
u/Dan6erbond2 Jun 16 '23
It's called a limit for a reason.
1
u/Flutter_ExoPlanet Jun 17 '23
I would like to get r/StableDiffusion before its gone in 2-3 days. Any idea how? (comments, images included)
28
Jun 14 '23
"Guys how do I make the very exact type of thing that made Reddit charge for API access, while not having the skillset to make it efficient, which is what Reddit complained about devs doing?"
3
u/F1rstxLas7 Jun 14 '23
Fuckin, chill? OP is asking a question in a learning Python subreddit.
Jesus christ, sometimes I wonder why these kinds of comments are made at all. This community is constantly being touted as helpful and friendly, but this is just mean.
15
u/QWxx01 Jun 14 '23
OP isn’t even attempting to learn anything. He’s begging for code instead of building something himself.
0
u/F1rstxLas7 Jun 14 '23
Lmao, no they're not. Did you read any of their posts? They're going throughout this thread asking for context and direction. Why can't people start a discussion to get help? Nobody here is begging for code at all.
4
u/nfgrawker Jun 15 '23
Looking for direction = "has anyone made code to download a subreddit." they are looking for a tool not trying to learn python. My gosh.
1
u/deadeye1982 Jun 15 '23
That is not the point!
People are simply afraid that Reddit will disappear at some point and all the posts will be lost.
That's why people try to save something before a platform disappears.
Reddit profits from the free work of its users. It's the same with other big platforms.
People used to be more intelligent and used small platforms, some of which still exist today.I can only advise everyone to register on python-forum.io and turn their backs on Reddit forever.
-30
u/Flutter_ExoPlanet Jun 14 '23
All I want is one subreddit.
Cannot it be done with HTTrack or something? ChatGPT told be it needed some tweeking but it appears to be complexe
17
u/Action_Maxim Jun 14 '23
This is why my job as a data engineer is safe
0
u/Flutter_ExoPlanet Jun 15 '23
Just curious, any idea why my comment was downvoted?
1
u/Action_Maxim Jun 15 '23
You come off as an incompetent ass hole and want everyone to do things for you that are easily googled this is a sub for learning python not to serve you.
You would have had success just posting code with the error saying you can't figure out what's wrong.
Your problem isn't unique go pay someone to solve it if you're not able to yourself
1
u/Flutter_ExoPlanet Jun 15 '23
why the "ass hole" thing?
I mean why SO ANGRY?
Dont get a heart attack or a brain seizure. Relax.
2
u/Action_Maxim Jun 15 '23
Lmao you asked and now you're butt hurt about the truth. You couldn't handle the truth
1
u/Flutter_ExoPlanet Jun 15 '23
It does not matter if I can handle the truth or not. My comment stands.
Also, I suspect the downvotes to come from Reddit allies probably. I mean, who is in this world angry at someone asking for handouts in a sub called "learnpython"?
1
u/Action_Maxim Jun 15 '23
You're looking for a handout not a way to pave your own way, you're arrogant thinking simply drop it in chat gpt and you'll be able to execute but you haven't used chat gpt to debug you're asking a teaching community to debug something for someone who has no intention of learning. You're not going to contribute to the community yet you feel entitled to help, that's not how this works. I learned on here and now I contribute.
1
u/Flutter_ExoPlanet Jun 16 '23
Things are not so simple, I am already learning other stuffs on other fronts, I'd thought at least SOMEONE has made the work and did not bother sharing their scraping method.
I have used chatGPT lot of times in coding and people over r/ChatGPTCoding know that you can't just rely on it to make complexe codes, I did not even want to bother debugging and thought it was worth it to find someone who already succeeded in it.
And few comments sugested tools that worked for them, will see how they work.
→ More replies (0)
1
u/mistabuda Jun 14 '23
Call the api. Find a sub. Grab all the posts. Find all children of each posts. Recreate the hierarchy locally.
1
u/Flutter_ExoPlanet Jun 14 '23
How much could this cost for a 250K users sub size?
Also, impossible to do without api?
7
u/mistabuda Jun 14 '23 edited Jun 14 '23
Without an api, learn how to use beautifulsoup.
The API is currently free so $0.00 is the cost.
If you are asking how much time it would take? Depends on how fast your computer is and if you leverage some kind of concurrency.
Doing this with beautifulsoup for a big sub? Idk I'm not a masochist but it will certainly be much slower than using the API outright
2
u/Agent-BTZ Jun 14 '23
beautifulsoup is nice. It’s pretty easy to use, & it was pretty quick when I used it to scrape article titles. Scraping the contents of every post & comment in a subreddit sounds like it’d be never ending though.
I bet someone could write a script that’d automatically upload posts to the wayback machine. Idk if that violates anyone’s policies, but that way only 1 person would have to fetch each post & it wouldn’t take up your disk space. Maybe someone could incorporate beautiful soup to make a catalog of the Reddit post’s titles, & then list it next to the corresponding wayback machine link…idk if anyone wants to take the time to do that though lol
1
0
u/Flutter_ExoPlanet Jun 14 '23
Thank you, would not reddit detect the IP going through all the pages of a sub too quickly and stop it?
Also, hasnt someone make the tool yet, I could learn to do it, But I am sure someoen already bothered doing it i would love to learn it
2
u/mistabuda Jun 14 '23
would not reddit detect the IP going through all the pages of a sub too quickly and stop it?
If that were to violate the terms and conditions then probably?
time.sleepWould be your friend if you are trying to throttle yourself.1
u/Flutter_ExoPlanet Jun 14 '23
ok thanks.
Where did you use BS in the past yourself?1
u/mistabuda Jun 14 '23
made a sneakerbot for fun as a google cloud function that ran on a schedule checking for things in specific sizes from specific brands.
1
u/Flutter_ExoPlanet Jun 14 '23
Nice. lemme pm you for a sec, just to keep contact for later if needed
1
u/Taichou_NJx Jun 14 '23
Beautiful soup is solid, been using it lately to scrape anime data from wiki, can check my page for the vids.
Regarding the api I was under the assumption that one call to could request multiple data point like post/comments etc… do we have know of each comment/post counts as a different call?
0
-12
u/Thecrawsome Jun 14 '23
chatgpt "pushift api python download whole sub's submissions with text and images and separate them into folders "
-4
u/Flutter_ExoPlanet Jun 14 '23
I tried with little effoert, did not get what I wanted, its very complexe
0
Jun 14 '23
[deleted]
2
Jun 14 '23
Definitely, all these sub mods want their power and their fedoras back
-1
u/EducationalCreme9044 Jun 14 '23
They should have just all voluntarily left. Love when the 1% totally controls the access to every community. They really think they are what makes Reddit.
0
u/Flutter_ExoPlanet Jun 14 '23
r/stablediffusion Not really.
0
24
u/krurran Jun 14 '23
Good question for r/DataHoarder