标签:str ecs proxy logs replace script 文章 utf-8 ict
参考上一篇文章
http://rpc.cnblogs.com/metaweblog/WeyneChen 从连接可以看到支持的metaweblog API
import xmlrpc.client as xmlrpclib import codecs serviceUrl,appkey = ‘http://rpc.cnblogs.com/metaweblog/WeyneChen‘,‘weynechen‘ blogid = ‘177230‘ cid = ‘782172‘ usr, passwd = ‘weynechen‘, ‘xxxx‘ server = xmlrpclib.ServerProxy("http://rpc.cnblogs.com/metaweblog/WeyneChen") #userInfo = server.blogger.getUsersBlogs(appkey,usr,passwd) #postInfo = server.metaWeblog.getCategories(cid, usr, passwd) recentPost = server.metaWeblog.getRecentPosts(blogid,usr,passwd,1) # for str in userInfo: # print (str) # for str in recentPost: # print(‘%(postid)s\t%(title)s‘ % str) f = codecs.open(‘main.html‘,‘r‘,encoding = ‘utf-8‘,errors=‘xmlcharrefreplace‘) des = f.read() post = dict(description = des,title = ‘metaWeblog Test‘) newPost = server.metaWeblog.newPost(blogid,usr,passwd,post,True) f.close()
目录下面有一个test.html,运行这个代码后,打开博客园可以看到内容已经放到了未分类中
标签:str ecs proxy logs replace script 文章 utf-8 ict
原文地址:http://www.cnblogs.com/WeyneChen/p/6670609.html