Skip to content

Instantly share code, notes, and snippets.

@alexrydzak
Created March 14, 2016 19:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexrydzak/177d9bf8d3817a930367 to your computer and use it in GitHub Desktop.
Save alexrydzak/177d9bf8d3817a930367 to your computer and use it in GitHub Desktop.
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