Skip to content

Instantly share code, notes, and snippets.

@nb
Created June 28, 2010 17:02
Show Gist options
  • Save nb/456101 to your computer and use it in GitHub Desktop.
Save nb/456101 to your computer and use it in GitHub Desktop.
# coding: utf-8
from xmlrpclib import ServerProxy, Binary
import pickle
import re
server = ServerProxy("http://path-to-not-so-random-wp-installtion/xmlrpc.php")
essays = pickle.load(open('essays'))
for essay in essays:
try:
match = re.search(r'<([^<>]+)>\s*$', essay['from'])
email = match.group(1) if match else essay['from']
print server.metaWeblog.newPost(1, 'admin', 'a$', {'title': '', 'description': Binary('<blockquote>%s</blockquote>\n\n<cite>От %s</cite>' % (essay['text'], email))}, True)
except Exception, v:
print "Error:", v
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment