zoukankan      html  css  js  c++  java
  • 使用python在wordpress博客网站添加新文章示例

    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)


  • 相关阅读:
    UVa 11389
    uva 1418
    uva 10905 Children's Game
    uva 471
    UVA 1508
    Uva120 Stacks of Flapjacks
    UVA 10020 Minimal coverage
    UVA434
    UVa 311
    决策树算法
  • 原文地址:https://www.cnblogs.com/AlexanderZhao/p/12879010.html
Copyright © 2011-2022 走看看