Created
March 14, 2016 19:59
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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