OldStory/Home Linux

Post using python script

Alnilam 2009. 6. 4. 18:52
반응형

$ vi blog_post.py
# Import needed libraries:
import xmlrpclib;
from pprint import pprint;
# Define the blog publishing function
def blogPost( server, username, password, categories, tags, title, content ):
  
    datastruct = {'description':content, 'title':title, 'categories':categories, 'mt_keywords':tags}
    returncode = server.metaWeblog.newPost('1',username,password,datastruct,1)
    print returncode

servname = xmlrpclib.Server("http://howto.homelinux.com/wordpress/xmlrpc.php")

# Initialize the settings
d_username = 'blog_id'
d_password = 'blog_passwd'
pprint(servname.system.listMethods())

n_categories = ['Home Linux']
n_title = 'python post test';
n_content = 'posting using python script.';
n_tags = ['test'];
 
blogPost(servname, d_username, d_password, n_categories, n_tags, n_title, n_content)

$ python blog_post.py

반응형