Tag Archives: tutorial

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

Vim Search and Replace: Grabbing Image URLs from HTML source code

The following is a quick and dirty way of pulling a lot of URLs out of a given pages source code, using two commands in vim, my new favourite text editor. So, right to the point!

:v/jpg/d
:%s/^.*src="\(http:.\{-}jpg\)".*/\1/g

Try it out right now on the source code of Imgur’s /r/ScarlettJohansson’s page

Continue reading Vim Search and Replace: Grabbing Image URLs from HTML source code

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

Git Beginner Tutorial

This was originally a comment on reddit, but I figure it’d help other folks out, so I’m going to put it up here too.

So git, is a great tool for backing up your code projects, allowing you to easily save and manage different versions of your project among your friends and coworkers. But despite all the friendly packaging, on github, it was really intimidating. I didn’t know what a branch was, let alone a fetch, merge or anything even more complex like trunks and  bisecting. Eventually though, I got the basics sorted out. It was enough to send (push) a few of my repositories over to github. This was my basic experience:

Continue reading Git Beginner Tutorial