使用Python脚本批量添加WordPress文章
我们用到Wordpress的xmlrpclib,步骤:
- 安装python 和 xmlpc。
- 然后用下面代码新增一篇文章:
importdatetime,xmlrpclib
wp_url="http://www.awaimai.com/xmlrpc.php"
wp_username=""
wp_password=""
wp_blogid=""
publish=True
server=xmlrpclib.ServerProxy(wp_url)
title="Thisistitle"
content="Thisiscontent"
date_created=xmlrpclib.DateTime(datetime.datetime.strptime("2011-10-2021:08","%Y-%m-%d%H:%M"))
categories=["categoryhere"]
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)
文章来源:http://panks.me/posts/2012/06/add-post-to-your-wordpress-blog-using-python-script/
热门推荐
10 香港老妈结婚祝福语简短
11 毕业立体贺卡祝福语简短
12 简短新年年会祝福语
13 评论小品祝福语大全简短
14 恭喜师兄结婚祝福语简短
15 员工集体辞职祝福语简短
16 高中新生祝福语 简短
17 装修祝福语男生搞笑简短
18 生日开业蛋糕祝福语简短