Created
February 4, 2015 21:38
-
-
Save danielpunkass/9c55e99af283ec0e24ec to your computer and use it in GitHub Desktop.
Example of using xmlrpclib to efficiently fetch the posted entry URLs for all posts on a blog...
This file contains hidden or 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 | |
import sys | |
import xmlrpclib | |
postLimit = 1000 | |
if (len(sys.argv) < 4): | |
print "Usage: %s <blogAPIURL> <username> <password>" % sys.argv[0] | |
print "E.g.: %s http://example.com/xmlrpc.php daniel 1234" % sys.argv[0] | |
sys.exit(0) | |
blogServer = xmlrpclib.Server(sys.argv[1]) | |
# All posts from 0 to postLimit, excluding all fields except 'link' | |
allPosts = blogServer.wp.getPosts(1, sys.argv[2], sys.argv[3], {"offset" : 0, "number": postLimit}, ['link']) | |
allLinks = [x['link'] for x in allPosts] | |
print "\n".join(allLinks) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment