Wodrepress是最近很火的一个博客平台,利用它可以快速搭建各种网站。下面我是利用xmlrpc编程接口在wordpress添加文章的示例代码:

import datetime, xmlrpclib
wp_url = "http://www.example.com/xmlrpc.php"
wp_username = "someuser"
wp_password = "secret"
wp_blogid = ""

status_draft = 0
status_published = 1

server = xmlrpclib.ServerProxy(wp_url)

title = "Title with spaces"
content = "Body with lots of content"
date_created = xmlrpclib.DateTime(datetime.datetime.strptime("2009-10-20 21:08", "%Y-%m-%d %H:%M"))
categories = ["somecategory"]
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, status_published)


相关文章:

  • 2021-11-04
  • 2021-08-26
  • 2022-12-23
  • 2022-01-01
  • 2021-09-20
  • 2021-11-05
  • 2021-05-23
  • 2021-07-07
猜你喜欢
  • 2021-10-21
  • 2021-08-30
  • 2021-08-02
  • 2021-05-09
  • 2021-10-18
  • 2022-12-23
  • 2022-03-05
相关资源
相似解决方案