使用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 50多岁生日简短祝福语
13 安徽疫情祝福语简短英语
14 农民朋友发财祝福语简短
15 对生活祝福语简短精辟
16 搬家词简短祝福语朋友
17 女神结婚快乐祝福语简短
18 文学短句祝福语大全简短