剧情介绍:
前面本渣渣分享了Python XML-RPC 自动(离线)发布Zblog博客文章,今天本渣渣继续接着分享最多人用的Wordpress博客博文的自动(离线)发布!
与Zblog自动发布有着大同小异,网络上有着现成的轮子,直接复制粘贴即可使用,非常方便,同样是使用的xmlrpc,不妨自行尝试使用!
安装 wordpress_xmlrpc 第三方库
这里本渣渣用的Python 3,需要安装一下第三方库:wordpress_xmlrpc!
代码语言:javascript
复制
pip install python_wordpress_xmlrpc
Python wordpress_xmlrpc 自动(离线)发布文章源码参考
代码语言:javascript
复制
# -*- 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:发布文章、新建标签和分类目录
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博客文章
Content retrieved from: https://cloud.tencent.com/developer/article/2022652.
影视信息:
影视信息
影视名称:
更新日期:2024-08-31 01:12:43
影视分辨率:
获取详情: 暂无资源
窗外天空