Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Grab the latest version number of a plugin from the Wordpress plugin API.
#!/usr/bin/python
# Alex Rydzak - <adrydzak@syr.edu>
# import necessary libraries
import requests
#==========================================================================
# set plugin name (usually something-something- no extension on the end)
plugin = "akismet"
# hit the Wordpress plugin information API for our plugin
wpquery = "http://api.wordpress.org/plugins/info/1.0/%s" % (plugin)
result = requests.get(wpquery)
# if the query was sucessful...
if str("200") in str(result):
print "[*] Request to Wordpress API worked..."
# grab the first line of the result from the query
grabfirst = result.content.splitlines()[0]
# split the returned string on the " character
grabcell = grabfirst.split('"')
# print the plugin version
print "[*] Latest plugin version for %s: %s" % (plugin,grabcell[13])
else:
print "[*] Something bad happened. Maybe you didn't spell the plugin name right?"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.