Category Archives: Python

How to delete spam comments on your WordPress blog, with Python via the Wordress API

In this tutorial we’ll be covering how to delete all those spam comments you’re getting posted to your
blog using the wordpress api via it’s fantastic Python wrapper, python-wordpress-xmlrpc, and make sure you’ve enabled the XMLRPC API on your blog.

How this script works is that it pulls all the comments that are in the pending
queue and then if it contains any words from the list of words that are likely spam words,
like ‘ambien’ or ‘oakley’, then take care of by deleting or marking them as spam. Here’s the full PasteBin of the script, and as usual, it’s also included in full at the end of this post.
Nothing too tricky, let’s get started!

Continue reading How to delete spam comments on your WordPress blog, with Python via the Wordress API

Imgur API part 3: OAuth2

It’s been a while since I wrote the last one, but a user on reddit asked how to get OAuth working with Imgur, and I couldn’t resist giving it one more shot. Thanks to my recent experience with the Netflix API, even though it was in C# rather than in Python, I was able to wrangle a quick and easy script for getting started.

Here’s the PasteBin with the complete code, thought it’s shown at the bottom of the page, as usual. Continue reading Imgur API part 3: OAuth2

How to scrape an ImageBam gallery for images with 30 lines of Python

Right off the bat, I want to show you the results of this scraping, to give you a bit of motivation. Anyways, thanks to requests and BeautifulSoup, this is made trivially easy. Enough talking, let’s get down to the code! Don’t forget that as usual I’ll include the full source code at the bottom of the post.

Continue reading How to scrape an ImageBam gallery for images with 30 lines of Python

Reddit API Tutorial Part 2: Getting all the submissions to any given subreddit

What’s up? Today we’re going to look at how to retrieve the stories (official term for submissions or selfposts) from any given subreddit. What we’re going to do is pretty simple, essentially just customizing a url with the proper subreddit and reading the JSON object returned. It’s going to be a pretty short one. I’m going to attach the login code I’ve written along with the code we’ve looked at today so that you can just copy and paste it into your IDE and start playing with it, right away. Just make sure you’ve got all the required module installed, mentioned here.  Hit the jump to get started!

Tinypaste Link for entire code

Continue reading Reddit API Tutorial Part 2: Getting all the submissions to any given subreddit