前面本渣渣分享了Python XML-RPC 自动(离线)发布Zblog博客文章,今天本渣渣继续接着分享最多人用的Wordpress博客博文的自动(离线)发布!
与Zblog自动发布有着大同小异,网络上有着现成的轮子,直接复制粘贴即可使用,非常方便,同样是使用的xmlrpc,不妨自行尝试使用!
这里本渣渣用的Python 3,需要安装一下第三方库:wordpress_xmlrpc!
pip install python_wordpress_xmlrpc
# -*- coding: utf-8 -*-
#微信:huguo00289
from wordpress_xmlrpc import Client, WordPressPost
from wordpress_xmlrpc.methods import posts
username="管理员用户名"
password="管理员密码"
apiurl="http://域名/xmlrpc.php" #网站xmlrpc路径
wp = Client(apiurl,username, password,)
print(wp)
post = WordPressPost()
post.title = '文章标题2'
post.content = '文章内容'
post.post_status = 'publish' #文章状态,不写默认是草稿,private表示私密的,draft表示草稿,publish表示发布
post.terms_names = {
'post_tag': ['test', 'firstpost'], #文章所属标签,没有则自动创建
'category': ['Introductions', 'Tests'] #文章所属分类,没有则自动创建
}
post.id = wp.call(posts.NewPost(post))
print(post.id)
发布成功效果:
参考来源:
1.python使用xmlrpc自动发布文章到wordpress
https://www.it610.com/article/1491513525284134912.htm
2.Python 使用 xmlrpc 操作 WordPress:发布文章、新建标签和分类目录
https://laowangblog.com/python-wordpress-xmlrpc.html
3.我用python和xmlrpc发布wordpress文章时,只是文字正常;但发布图片却不行,怎么回事?
https://www.zhihu.com/question/60636568
4.python-wordpress-xmlrpc 2.3 documentation
https://python-wordpress-xmlrpc.readthedocs.io/en/latest/overview.html
相关阅读:
Python XML-RPC 自动(离线)发布Zblog博客文章
·················END·················
你好,我是二大爷,
革命老区外出进城务工人员,
互联网非早期非专业站长,
喜好python,写作,阅读,英语
不入流程序,自媒体,seo . . .
公众号不挣钱,交个网友。