본문 바로가기
OldStory/Home Linux

Post using python script

by Alnilam 2009. 6. 4.
반응형

$ 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

반응형

'OldStory > Home Linux' 카테고리의 다른 글

Open Clip Art Library  (0) 2009.06.17
python post test  (0) 2009.06.04
XML-RPC servers for Python  (0) 2009.06.04
[Ubuntu] SCIM 한글 입력 설정  (0) 2009.05.28
Wandering In The Sky  (0) 2009.05.15