So, we do not have SSL service with our CDN (Akamai). When accessing https://www.reddit.com, you just got the default Akamai certificate, which was not valid for reddit. It may have worked, but it was invalid, and we were not paying for it.
Since we weren't paying for this access but people were using it, it looks like Akamai made a change to just prevent it from working entirely (instead of just sending a generic certificate).
We're going to get site SSL one day, but it is pretty damn pricey to do so through a CDN. It will likely be rolled out for logged-in users first.
Hot and controversial are here: https://github.com/reddit/reddit/blob/master/sql/functions.sql
Rising is here: https://github.com/reddit/reddit/blob/master/r2/r2/lib/rising.py
New should be blatantly obvious to anyone who can understand the hot or rising algorithm.
In a comment/post? Put two spaces on the end of the line: https://daringfireball.net/projects/markdown/syntax#p
> When you do want to insert a <br />
break tag using Markdown, you end a line with two or more spaces, then type return.
If it's for a sub you own then you can use scheduling in AutoModerator.
If not, you may not need a bot/VPS. ifttt.com might suffice. You can set up applets to schedule posts at specific times.
I'm not that good so please no one crucify me if I make a mistake.
Any takes either a generator expression or a list and will return True if any of the items are true.
>>> lst = [True, False, True, True] >>> any(lst) True >>> lst = [False, False] >>> any(lst) False
A generator expression iterates through the results, requiring less memory and useful for lots of data. Unless you have thousands of keywords, it won't really matter.
Either of the following would work. One is using list comprehensions and the other is a generator expression.
>>> has_keyword = any(k.lower() in comment.body.lower() for k in keywords) # any() using a generator expression. >>> has_keyword = any([k.lower() in comment.body.lower() for k in keywords]) # any() using list comprehension
See how you can do the same thing without using list comprehension.
>>> text = 'BLACK BLUE RED GREEN' >>> keywords = ['purple', ['Blue'] >>> has_keyword = any([k.lower() in text.lower() for k in keywords]) >>> print(has_keyword) True >>> has_keyword = False >>> for k in keywords: >>> if k.lower() in text.lower(): >>> has_keyword = True >>> break >>> print(has_keyword) True
I'm going to be distributing a client app that uses the Reddit API (actually, a Chrome extension), and I decided to cache any data I get from the API for at least one minute. That way, the users won't be requesting the same page more than once per minute, and ideally they won't be requesting anything more often than once per two seconds.
Do the best you can do to decrease the load on the Reddit API, and if you're really worried jump on Freenode IRC and join the #reddit-dev
channel to ask the admins if your app will be okay.
Also, be sure to check out the API wiki. I'm currently writing it, so it's not complete, but what pages are done should be helpful! :D
If you are not breaking your schools T&C then you can download miniconda. It is a self contained python distribution, meaning you can install whatever you want in your user directory.
I think it includes 'pip' but if not then you can do 'conda install pip'. After that just use pip to install whatever you like.
For some reason, it's not documented, but reddit gold users can filter to a specific subreddit.
https://www.reddit.com/user/{somebody}/saved.json?sr={subreddit}
e.g.
https://www.reddit.com/user/kemitche/saved.json?sr=redditdev
At first glance, everything seems to be looking more or less correct. Sole exception being that you don't seem to be setting a unique User-Agent header (see the rules).
Beyond that, it may help to examine the raw request being sent to verify that it looks as you expect.
(Also of note - you should store the uuid somewhere on the device and re-use it).
Yes, it is legal.
The reddit code is licensed under the Common Public Attribution License. I believe the main stipulations are any changes to the code must be publicly available and you must clearly state on your site you are running reddit code.
Check out the license for more information: https://github.com/reddit/reddit/blob/master/LICENSE
thanks, I had to do some googling to know figure out what you meant, but eventually this function worked for me. cheers /u/radd_it.
Try this:
https://www.mediafire.com/folder/aisdohhd4ozye/jarfiles
They were compiled on a Mac, but that shouldn't make any difference at all, regardless of what your system is. Ping me if you have any problems with these jars.
Run or proxy the site through nginx, and set up HTTP Basic Auth in nginx.
If you're going to be running a blanket catch like that, you should be also logging the exception in some manner, otherwise other exceptions will be caught and masked from your attention.
Here's a few useful things for you too:
A useful article on logging in Python.
An example script where I except RequestException
Hopefully these are helpful.
Use the /r/subreddit/about endpoint. The result will have description
and description_html
fields that you can parse to get what you're looking for.
Here is a live demo you can poke around with.
Others have suggested keeping the password file out of your repository. Some other options for having the password in your directory:
Create a generic configuration file with the structure and placeholders for your username and password and call add a .dist extension to the end to let people know that they have to copy it and add their details. Add the actual config path (not the dist) to your gitignore file.
create a config like above, but don't add .dist. Commit it and then use git update-index --assume-unchanged configfile to ignore changes to that file. Then change the password locally. Keep in mind that update-index only works for your clone. http://git-scm.com/docs/git-update-index
This is obviously all assuming that you use Git.
Another option would be to use environment variables, and read those from your program.
Reddit messages, sure, but it's not possible to send an email to a redditor if you don't know their email address. However, since you said they were your friends, I'm assuming you do. There are a few ways to do that:
To find the latest post should go something like this:
import praw import smtplib
r = praw.Reddit(user_agent = "/r/test newsletter")
latest_emailed = "" test = r.get_subreddit("test")
while True: latest_post = test.get_new().next() if latest_post.id != latest_emailed: """smtplib stuff"""
Using AutoMod to schedule posts is only an option in a sub that you're a mod of, or if you can convince a mod of another sub to allow you to schedule posts.
For ifttt, you need to sign up and then you can make your own applets at https://ifttt.com/create. You'll go through several steps, picking your triggers/actions as you go.
A PRAW user has an is_gold
attribute. Looking at your profile's response, your is_gold
is set to true
.
import praw r = praw.Reddit(user_agent="Testing Bot")
user = r.get_redditor("youareinthematrix") print(user.is_gold)
Well, what skills do you have? Reddit is a lot less flexible than Wordpress because it's not really meant as a platform to be run on multiple servers as an end-user product. It makes a lot of assumptions and expects only exactly certain tools.
However, if you're comfortable with the fact that it will take some effort, here's the install guide.
https://play.google.com/store/apps/details?id=com.andrewshu.android.reddit
If you do all the things you ask about, you'll be just another one of dozens of apps doing the same.
Reddit might very well have legal right to ask you to cease and desist, but they haven't demonstrated much interest in doing so.
Please always declare your cross-posting, so that people may check your duplicates for answers before expending time on writing out another.
If you thought adding Python to your path was steep then the bot is going to take a while. The bot basics are all in the docs but if you don't know any Python then you'll probably struggle to get much further. The codecademy tutorials might be worth a look.
You can execute a PHP script through the command line with the php
binary:
php myscript.php arg1 arg2 arg3
See here for more information.
We're waiting for gandi, our CA, to support it: https://twitter.com/gandibar/status/509116131173748736
Edit: Oh, it looks like they added support recently.
Would this be similar to what you're looking for https://lobste.rs/ ?
There's also http://meta.telescopeapp.org/ which has voting capabilities and the threads can be sorted by Top New Best Daily
Both are open source and would probably be easier to set up than Reddit.
Looks like html2text itself maintains some state, such that it returns different strings if you pass the same text to the same HTML2Text
object more than once. Note the extra \n\n
at the start of line 7 that wasn't there on line 5:
>>> import html2text >>> h = html2text.HTML2Text() >>> h.ignore_links = True >>> h.handle("<p>Hello, <a href='http://earth.google.com/'>world</a>!</p>") 'Hello, world!\n\n' >>> h.handle("<p>Hello, <a href='http://earth.google.com/'>world</a>!</p>") '\n\nHello, world!\n\n'
I'm pretty sure in needs to be a header. An example for headers in HTTParty would be:
HTTParty.post("http://rubygems.org/api/v1/gems/httparty/owners", :query => { :email => "" }, :headers => { "Authorization" => "THISISMYAPIKEYNOREALLY"})
That's what I found online here for headers in HTTParty
Very good solution. And for anyone else who found this through googling but is afraid of terminals, youtube-dlg is a simple and to-the-point frontend for youtube-dl.
You're really going to hate this answer but to understand how Reddit works you need to watch videos 10-29 from this playlist. It's Reddit co-founder Steve Huffman (spez) discussing Reddit architecture with Reddit's lead engineer (at least at the time).
To better understand the concepts in the videos as well as others, you might want to just take the entire course from Udacity. It's free unless you want a tutor and certificate of completion.
I've written a few things with praw using python 2.7.x, and more recently, 3.3.0. Strings are unicode by default in Python3, so you shouldn't get errors like the one you're asking about.
If you're not already using it, I'd look into pyenv and its virtualenv plugin. Pyenv makes using multiple versions of python simple, and virtualenv is virtualenv.
Yes, I have a couple of small apps on app engine and one runs regular cron tasks to process and cache remote data.
Edit to add doc links:
>Do Amazon expect you to hand over any payment details, personal information? How easy is registration?
Credit card info
>So they use a fedora/redhat/centos system (i had to look up yum, i use debian)
https://aws.amazon.com/marketplace/b/2649367011?page=1&category=2649367011
for a list but free only get to pick like 8. There are debian systems you can use though I believe.
>can you install pip nice and easy with yum? How does it handle praw/reddit logins, i know pythonanywhere doesnt like praw going through SSL.
Same as apt-get really. sudo yum install pip. sudo pip install praw. It works fine on there for me.
>Finally are redditbots pretty stable on it? Pythonanywhere will switch your bot off after a few days if its going over its CPU allowance, is EC2 more generous?
I've only been using it for a few days but so far so good.
http://aws.amazon.com/free/faqs/
There are the limitations you get for free. If you go over you pay for that month but I believe you still get the 12 months for free. But I don't think you'll go over if you are only searching and replying.
I read that if you are always at 100% CPU they will throttle you but you won't notice as they just lower your speed, but you'll still be at 100%. Not sure if it really matters, I'll notice or if it's true.
Reddit actually DOES allow cross origin requests, no idea why it's not working for you. Can you check your network tab and see if the request contains a proper Origin header/response contains access-control-allow-origin header?
Here's a bin to demonstrate that it works: http://jsbin.com/qacipuk/edit?html,js,output
Btw you're using fetch/promises kind of wrong, though it should not be the issue here. It yields a Response object, so you need to call either text()
or json()
on it (which also returns a promise). And to add an error handler you need to pass it as a second argument to then
, calling it twice simply adds another success handler to the chain.
1. Can you post a gist or your code?
2. Yeah, but there are other ways to stop the submission_stream, such as forcing an error and catching it after a certain amount of time, like here's an unconventional use:
class SubmissionStreamBreaker(Exception): pass
counter = 0 try: while True: # By Default the session is always True for post in praw.helpers.submission_stream(r, 'IAMA', limit=None): count +=1 # do something to posts if count >= 37: # we did something for 37 new posts # it's time to do something else now # raise the exception that was made so that it is # caught and then continue raise SubmissionStreamBreaker('Break It') except SubmissionStreamBreaker: pass #do something else now.
You don't have to put it in a relational database. MongoDB is a noSQL database that stores data as JSON objects. You can set up a cluster in the cloud. MongoDB offers a free tier if you want to try it out https://www.mongodb.com/cloud/atlas/register
Thanks. LIKE
is pretty slow; if space isn't highly restricted you can take a look at FTS which speeds up the process extremely.
An example from the linked doc:
SELECT count() FROM enrondata1 WHERE content MATCH 'linux'; / 0.03 seconds (FTS) / SELECT count() FROM enrondata2 WHERE content LIKE '%linux%'; /* 22.5 seconds (Standard) */
> if you were designing it from scratch how would you design it?
I'm not really sure. I've been thinking a bit about that recently, but haven't really dug in enough to get a strong feel yet. I suspect something like Netflix's Dynomite would figure in at the more macro scale for scalability and redundancy, but the micro level is less clear to me. The lack of schema in the Thing model is super convenient for development, but it does sometimes have performance downsides. Depending on where I'm feeling about it that day, I think of a more relational model with proper columns and data types, or something closer to the Thing model we're talking about here, but using JSONB from recent Postgres versions to replace the data tables.
We'll surely be thinking much more concretely in the coming months. Stay tuned!
> Thanks btw.
of course, please keep the questions coming :)
That is very very weird.
https://stackoverflow.com/questions/13207450/permissionerror-errno-13-in-python may elucidate what is happening, but I have little idea why. Try attaching a debugger and going through the current state when it next crashes?
Can you paste the code for your logger setup section? That may help.
More long term it may be worthwhile running your script in a virtualenv. That way it will eliminate any weird permissions issues you may encounter in your general python setup.
reddit provides a webhook to ifttt to do it though (https://ifttt.com/reddit/triggers/new_post_in_subreddit). so OP can probably do it through ifttt if he really wants to use webhooks and not polling. however, it seems ifttt requires a pro account to query data directly and/or add filter code.
Simple triggers can be handled by IFTTT.com. As you go more and more complicated, the complexity of an automated bot-writing app increases exponentially, to the point there's no point NOT writing it in a programming language anyway.
The lobster story is true: http://www.snopes.com/photos/signs/receipt.asp
And this should be stopped.
Also, this is called EBT instead of "food stamps" because "food stamps" would make the recipients "feel bad". GWB vetoed the bill that mandated this change, but the veto was overrridden.
That being said the current system is less subject to fraud than the systems in the past.
I've run into a bit of a bug. I'm trying to convert urls to the api.reddit.com hostname as i've only become aware of it after reading this post. However it doesn't seem to respect the context parameter. The two links below should be the same but only the www.reddit.com hostname seems to respect context.
Cheers
Dave
Edit: I don't think the context number is being respected in either case?
Drop the syntax
parameter. If that doesn't work, turn on logging for the requests
module, capture the final URL that you're hitting, and paste the exact URL here.
Unfortunately not, I haven't been working on the project since.
I did consider at the time to look into AWS Lambda. My thought was that maybe that you would get a unique IP address for each network request. I never tested this though so I can't say if that's true or not.
What are you working on and is it necessary for the server to make the request? If it something a user could immediately I don't think there would be any rate limit problem.
click this link presumably what you see is your frontpage in json format. If you were to send this same request from a different domain (not your browser) you would get the default home page (r/all: see demo*), which is what I get.
What I need to know is how to get "expected" data (your front page, like when you make a request/link from your browser).
How does reddit know my browser from someone else given only a url? How is it authenticated/logged in?
demo*
GETing /message/inbox/ doesn't remove entries from the inbox, it just marks them as read. Subsequent calls to /messages/inbox return the same messages, unless you have been sent new messages in the meantime. GETing /message/inbox.json has the same behavior except it does not mark the messages as read.
If you're interested in fetching subsequent items from the inbox, look at the 'after' value, towards the end of the json object. Plug that value into another call like so /messages/inbox.json?after=_____ and you'll get the next 100 messages in your inbox.
You can see my python code at the bottom of this file to see what I mean: https://github.com/theycallmemorty/reddit-hacks/blob/master/redditclient.py
Let me know if you're experiencing different behavior than what I'm describing. It'd be nice to get this documented in the wiki.
There may be 2 config directories. You should go to the one reddit/r2/r2/config to find routing.py.
As to running it, you should absolutely have Linux, unless you plan to spend many hours tweaking 4 different programs and 25+ Python libraries to play nice with Windows.
This is the guide to doing it by hand. And this is an automated script. There used to be a Virtual Box image that you can get up and running in 5 minutes, but I don't know what happened to it.
If reddit is rethinking things, I would like to take this opportunity to point out how discord bots work. The most important difference is that bots are clearly marked and attached to an existing account on creation rather than being a separate account. But also the creation process is much cleaner. It's only a few clicks and you only need the client ID and secret to login, no elaborate oauth process.
The api documentation is also much more elaborate. Here's an example. It has example json responses, all the fields returned are explicitly listed. While the basic operations are REST, it does also have websocket connections for announcing new messages or events.
I know this announcement doesn't mean reddit is actually going to rebuild their entire API, but if they are shifting more towards treating bots as a separate class of users, this might be a good opportunity to add in some more bot like API actions.
There are some hypothetical ways around this, but nothing within the realm of possibility.
You should be getting pylibmc and libmemcached6 from the reddit ppa https://launchpad.net/~reddit/+archive/ubuntu/ppa which is configured as part of the install script (and should have been configured when you first installed the reddit code).
Maybe try doing
sudo apt-get update sudo apt-get remove libmemcached6 python-pylibmc sudo apt-get install libmemcached6 python-pylibmc
Learning to program includes a lot of googling and using your discretion to determine if what you're reading applies to your problem at hand. It's fun if you enjoy that kind of thing, and it's challenging.
For bot development, the easiest information to find is for PRAW, the Python Reddit API Wrapper. Within a python script, you use the praw library to interact with the reddit api. Before you can do anything like post or reply on reddit, you have to register the bot with reddit so it can act on behalf of a reddit user account. There are plenty of guides on how that works.
If you want to get straight into python immediately, I really like https://repl.it. You can choose a programming language and build code in the browser and then come back to it later. You can run bot code in repl.it, but not for continuous use 24/7. When the bot is ready to go, run it from your computer at home or put it on a VPS (I use a cheap one on ramnode for $15/year). It could run easily on a raspberry pi.
When you get stuck on this project, pause for a moment and clearly define the exact thing you're trying to accomplish, even write it down. It's not rocket science, but anything new is not easy, and even though you'd think programming would be extremely logical, computing is brimming with idiosyncrasies and things you wouldn't know until you read it. So read lots of documentation. Hope this gives you a sense of what this sort of hobby entails.
node promise rejection
(node:17767) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict
(see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 17)
(node:17767) UnhandledPromiseRejectionWarning: Error: snoowrap refused to continue because reddit's ratelimit was exceeded. For more information about reddit's ratelimit, please consult reddit's API rules at https://github.com/reddit/reddit/wiki/API.
I need to test against it because snoo doesn't have the ability to add a catch block to the stream items. It uses a listener instead, ~ whatever.on('error', callback())
I'm not going to be hitting the rate limit for any periods of time, but I do need to crank up my test app beyond a reasonable rate and hit these for testing. I just need to know how to properly differentiate my test app from my production app, so the production app doesn't start hitting the limit. Up until this point I thought rate limits were based on ip address or something, but they both hit rate limits at the same time after I did my mini-flood on the test app
The docs say:
> If you're fetching comments from a thread with more comments than the API will return in a single response, the last comment will look like this: blah blah blah
No matter when I do with that thing, it keeps giving me the same answer. It might not be implemented, because when I give it garbage instead of a comment fullname, it still gives me the original page.
If you don't have any coding experience and don't want to actually learn how to scrape, Zapier has an App with reddit and one of their actions/events is adding rows to a google sheet: https://zapier.com/apps/reddit/integrations
> I was playing around with that, too. I just thought the php/karmalytics route would be better because I don't need to run it locally.
This is a good point. I've got a few remote machines, so I forget that not everyone has that. I know you can get a virtual machine for 5 bucks or so a month. Anyway...
Reply to the parent? So someone calls the bot and you want to respond to the comment above that one?
You want something like this:
for comment in reddit.get_mentions(): parent = comment.reddit_session.get_info(thing_id=comment.parent_id) parent.reply('Hi Mom!')
edit: yeah Digital Ocean will get you a VM for $5 a month. Might be useful if you're going to be doing bot development.
The code is nice, but it doesn't show at a glance what the request & response headers end up. Many libraries add headers automatically, so you should provide a dump of the actual requests being made using appropriate logging mechanisms. It's also easier for us, as we don't have to go learn whatever language & framework you're working in, and can focus on the actual API requests.
That said, the most likely culprit is as /u/rram stated: Forgetting a unique User-Agent per our API rules.
A bot that compiles every robots.txt and puts it into a file is not only very difficult to make (there is no definitive list of subreddits) but is the same thing as the /r/Bottiquette one. There is a bot running that adds subreddits to the list when messaged (the format).
I don't think reddit provides traffic sites for wiki pages, so I don't know how many bots are using the file. I'm still getting messages about the file so I presume quite a few bots are already using it.
The issue appears to be correlated with a migration from Akamai to Cloudflare:
$ host www.reddit.com www.reddit.com is an alias for www.reddit.com.cdn.cloudflare.net.
So something may have changed in the "return a cached logged-out webpage" logic.
My bot is broken in yet a third way; it can't resolve www.reddit.com
at all.
On the plus side, reddit is now available over SSL.
> If you want to understand the infrastructure kaisermagnus is talking about, reddit founder and current CEO Steve Huffman taught a free Udacity course on web development and spends almost an entire lesson covering reddit infrastructure. From app servers, cache servers, DNS load distribution etc.
Try this pattern, it will even leave out the ?context parameter
(https?://[www.]reddit.com/r/[a-zA-z]/comments/[^\s][^)?]+)
Use the built in regex module (called re)
I'm currently using Atom with the script package. I was thinking of switching to PyCharm anyways, but this has pushed me over the edge. (The script runs now :D)
I have same problem. How i can see problem with port (google groups topic https://groups.google.com/forum/#!topic/reddit-dev/lBn81riBptk) :
error message (constantly, after update touch run.update make
Jan 27 09:00:47 dragon807 reddit-paster: ConfigParser.InterpolationMissingOptionError: Error in file /home/reddit/reddit/r2/run.ini: Bad value substitution: Jan 27 09:00:47 dragon807 reddit-paster: #011section: [server:main] Jan 27 09:00:47 dragon807 reddit-paster: #011option : port Jan 27 09:00:47 dragon807 reddit-paster: #011key : http_port Jan 27 09:00:47 dragon807 reddit-paster: #011rawval : %(http_port)s
port = 8001
However, when i change port (and update haproxy.cfg) - it looks like not work. However one or two times i was lucky and server was able to bind to socket and i am opened reddit on local domain (it was very slow by the way!).
However after restarting it stop working. I am tried to find what the software using port 8001 with netstat -an | grep ":8001" but without luck (empty output), same with lsof -i :8001.
Please help! Unable to start using local reddit because of this problem.
PS: I am able to start reddit with command: paster serve --reload runprod.ini http_port=8004
(runprod.ini - my configuration). However standard wrappers return that error message.
This limit is not written anywhere "official". Here's a reddit-dev discussion about it from the beginning of the year:
https://groups.google.com/d/topic/reddit-dev/y_BaqD3QPeU/discussion
As far as I know, you can only go 1000 links back on each subreddit/sorting method combination.
Looks like this is an issue with curl itself following multiple redirects or something. I found the solution here to a different problem that I just happened to have just experienced with curl.
https://groups.google.com/forum/?fromgroups=#!topic/twitter-development-talk/rNy0uvdgN8g
You need to add --location --referer ";auto" to your options.
No, I was typing it straight into my Javascript. I found the problem - left off the last close-paren ")". Thanks for showing me that syntax.
Here's what I found for documentation on it, but only once I knew "cloudsearch" as a keyword.
https://groups.google.com/forum/?fromgroups=#!topic/reddit-dev/SarzNxbLSzI
What type of bot are you looking to run? What language?
~4 years ago I used App Engine to host some small web projects, but I do not know there current "free tier" setup nowadays or if it would be enough to run a bot 24/7.
If you are writing a "tool" of some sort, I've used https://pages.github.com/ in the past to host bots written in client side JavaScript. The downside of this is that authentication only lasts for 1 hour before needing re-authentication. It's enough time to do some tasks such as cleaning up user comments based on "x", making graphs of a users comment history, etc. The plus side to using GitHub pages would also be that they handle all the deploying of the code & it's easily accessible in browsers.
Here's a bit more :)
http://stackoverflow.com/questions/6532486/supervising-virtualenv-django-app-via-supervisor
So follow those first instructions but set the virtualenv PATH as per that second link's answer. Should be good to go!
depends on the web server and distro, I have no experience setting up a Reddit server, I'm only speaking from general web server knowledge.
This might be of use to you: https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-ubuntu-14-04-lts
I'm guessing you need to tell Apache where the Document root for Reddit is located I believe "It Works" is one of the default pages Apache servers the first time you set it up.
I'm on windows right now, so I use PuTTY. Here's a guide Digital Ocean put together: Link.
This is a guide for putting together your first droplet, which is pretty much a server.
If you have sufficient error handling in the script itself then you should be able to catch any exceptions and allow it to start over again. If you search the sub for 'exceptions' then you'll see a bunch of old related PRAW posts showing how to apply them.
One example that the author has linked to before is this.
Along the same lines as what TheSox mentioned, I'd recommend using byobu (Linux package) as it allows you to have multiple 'screens' (like tabs) in the terminal. Handy for leaving a long-running script open in one tab, then others for general use (viewing logs, apt updates etc).
For logging I use something like
0 * * * * /usr/bin/python3 /home/me/bot/bot.py >> /home/me/bot/bot.log 2>&1
Try downloading this cert file
http://curl.haxx.se/ca/cacert.pem
And then specifying it in the pip command
pip --cert cacert.pem install certifi
Make sure your command prompt is in the directory the cert is.
Two options:
As /u/13steinj says, you can use pip. pip freeze
will output dependencies and their versions to standard output -- merely redirect it to requirements.txt. Create your virtualenv on the remote side, and run /path/to/virtualenv/on/remote/bin/pip install -r requirements.txt
. Finally, run your script using /path/to/virtualenv/on/remote/bin/python
and be happy.
If you're using shared libraries, you can ensure the versions of such using docker to create a complete system on your end and deploy it on Amazon.
Good luck.
If your goal is to run the bot on a different machine (i.e. a dedicated server), then you don't need to install bash on your own machine. You just need an SSH client like PuTTY so that you can interact with the server.
I'm super new to anything remotely deeper than connecting a computer to a home network and I've managed to figure my way through ssh and terminal commands pretty easily. If you have any experience with the Windows command prompt it's even easier.
Also, there's Levinux, which is a tiny (22mb) Linux faux-server specifically for messing around and learning dealing with servers.
I agree with that, but there's other issues.
From here, I was led to the RFC 8252 I mentioned above, which says that the current best practice is to use an external user agent, such as the browser, so that users can more easily trust that the app is not capturing their authentication details. However, apps need a way to get back into themselves with the code intact. Section 7 describes ways to do this, with things like intent filters in Android, but literally any other app, not even a MITM that has to deal with SSL, can just use the same exact mechanism to make their app do it instead, therefore obtaining the code. As such, it states that PKCE is recommended for use on both the client and server to ensure code legitimacy in Section 8.
Well, I'm not super familiar with how Flask does sessions, but based on their guide, putting the info in the session leaves it in plaintext for the user to read and means it could be intercepted (unless you use SSL). You probably don't want that to happen.
Instead, you would want to do something like store their reddit username in the session, and then, on the server side, have a database or other data storage that maps usernames to the access info. Better explanation on StackOverflow - you want method #1.
Yeah. Not a huge Php fan but I do enjoy working with Laravel. Since this morning, I have decided to build my web-app with Django (python). I figured Reddit itself is built on Python, may as well follow suit.
I see, but I think you can run 2 processes at once on a free Dyno account no? https://www.heroku.com/dynos#
Not ideal, but you could always make a second account on there, or on a site like www.PythonAnywhere.com. But tbh, my experience is that sooner or later you'll have to start paying :/ Perhaps you can monitize your bot by adding a donate button or something? It's one of those things that doesn't have a perfect solution unfortunately
Redis wouldn’t be that bad. You can set keys to expire after a certain period of time or you can set a max size of the db and have it automatically delete the least recently used key. I’m using redis in my bot. You can see an example in its code. I’d recommend looking into a cloud host for your bot. AWS is great but I’m using heroku and I love it. It’s completely free and has free addons for things like redis, error notifications, logging and more. If you’re interested, I could help with that stuff. Just DM me if you’re interested.
Once you stop the program, the program exits.
I'd suggest running it in cloud. Get an AWS ubuntu instance, make it run indefinitely. Bonus points if you use a container based approach using Docker to keep it in a sandboxed environment.
you could also use heroku to deploy your bot.
PM me if you want any help :)
Your code isn't clear, working with thing.thing.thing doesn't help. Try adding intermediate variables.
You need some kind of recursion (or stack).
Here's what I came up with: http://jsfiddle.net/FRQ9b/9/
it was imgur, but now it's not doing it. i changed my getJson request to https when I was getting another error.
https://codepen.io/theguyinthechair/pen/ZOwAgd
all the images seem to be loading now and no 403
Try PyCharm, you'll like it.
As I said before it can manage your virtualenv (it's in the "interpreter" section of your project's setting).
Using a virtualenv is second nature to any experienced Pythonista and we rarely notice that there's actually no sign post to guide the new users there.
If you're looking for an already-made way to access the Reddit API using JSONP, I started a project that should help you out called JSONP-Fu.
If you're just hacking around for fun though, then by all means, carry on.
It's outsourced to Sendbird.
The Sendbird API works, mostly, with some weird tweaks to some of the APIs you call. None of those tweaks are documented, but you can use your broswers Network Manager to determine a lot of it.
https://sendbird.com/docs/chat/v3/platform-api/getting-started/prepare-to-use-api
For the 2nd part making it look like my app seems to be something other apps do.
For instance the popular "Red Reader" app on github does this:
(see CSS_FIXES
)
Go to your feeds and copy the RSS link for 'unread messages'.
Go to IFTTT and make a new recipe.
Done.
Haha, you are welcome! Maybe you could try Infinity for Reddit on your Android device if you have one. It's developed by me. 😁
Yeah that’s it! It’s about the size of a deck of cards. But don’t be fooled! It’s a surprisingly capable computer. You can connect to it with USB and HDMI to use it as a desktop or connect to it remotely through ssh. Here’s a link to one on amazon:
As far as I can see, user info can only be obtained via /user/<username>/about.json, so whether you're using the API directly, or via a wrapper, you need to use the name and not the fullname.
You can only discover the fullname by querying the user by their actual name to begin with (aside from manually digging into the HTML), so how could you even query them by fullname in the first place? Maybe I'm missing something?
Out of curiousity, why do you want to use their id instead of the user name?
If you're using Android, you can use Termux and install Python/PRAW and use it that way, for quick testing on the go.
My go-to is reddit sync , for its many many awesome options (browsing comments with arrows to jump between root comments, night theme , (material) design, link handling etc etc , it's awesome.
Others have also chosen Baconreader