使用Python脚本批量添加WordPress文章

2022-09-04 0 915

我们用到 WordPress 的 xmlrpclib,步骤:

安装 python 和 xmlpc。
然后用下面代码新增一篇文章:

代码:

 import datetime, xmlrpclib

wp_url = "http://www.awaimai.com/xmlrpc.php"
wp_username = ""
wp_password = ""
wp_blogid = ""
publish = True

server = xmlrpclib.ServerProxy(wp_url)

title = "This is title"
content = "This is content"
date_created = xmlrpclib.DateTime(datetime.datetime.strptime("2011-10-20 21:08", "%Y-%m-%d %H:%M"))
categories = ["category here"]
tags = ["sometag", "othertag"] 
data = {'title': title, 'description': content, 'dateCreated': date_created, 'categories': categories, 'mt_keywords': tags}

post_id = server.metaWeblog.newPost(wp_blogid, wp_username, wp_password, data, publish)

print(post_id) 

本文章已结束,如转载请注明:汇站网 » 使用 Python 脚本批量添加 WordPress 文章

收藏 (0)

微信支付 微信扫一扫

支付宝支付 支付宝扫一扫

打赏二维码
点赞 (0)

站长资源下载中心-找源码上汇站

常见问题
  • 如果付款后没有弹出下载页面,多刷新几下,有问题联系客服!
查看详情
  • 本站所有资源版权均属于原作者所有,这里所提供资源均只能用于参考学习用,请勿直接商用。若由于商用引起版权纠纷,一切责任均由使用者承担。
查看详情

相关文章

联系官方客服

为您解决烦忧 - 24小时在线 专业服务