Logo

Python发布WordPress文章

photo

2021年12月11日

安装

pip3 install python-wordpress-xmlrpc

pip install python-wordpress-xmlrpc

pip install python-frontmatter

使用

from wordpress_xmlrpc import Client, WordPressPost
from wordpress_xmlrpc.methods.posts import NewPost
import frontmatter
from wordpress_xmlrpc import Client, WordPressPost
from wordpress_xmlrpc.methods.posts import GetPosts, NewPost
from wordpress_xmlrpc.methods.users import GetUserInfo
from wordpress_xmlrpc.methods import posts
from wordpress_xmlrpc.methods import taxonomies
from wordpress_xmlrpc import WordPressTerm
from wordpress_xmlrpc.compat import xmlrpc_client
from wordpress_xmlrpc.methods import media, posts
import datetime
import sys


def sends():
    wp = Client('http://网址/xmlrpc.php', '用户名', '密码')
    filename = r'C:\Users\zhaosheng\OneDrive\markdown\PyTorch常用代码段整理.md'
    with open(filename, 'rb') as html:
        post_content_html = html.read()
    post = WordPressPost()
    post.title = "Quicker"
    post.date_modified = datetime.datetime.now()
    post.content = post_content_html
    post.post_status = 'publish'
    post.terms_names = {
        'post_tag': ['quicker'],  # 文章所属标签,没有则自动创建
        'category': ['quicker']  # 文章所属分类,没有则自动创建
    }

    post.custom_fields = []  # 自定义字段列表
    post.custom_fields.append({  # 添加一个自定义字段
        'key': 'price',
        'value': 3
    })
    post.custom_fields.append({  # 添加第二个自定义字段
        'key': 'ok',
        'value': '天涯海角'
    })

    wp.call(NewPost(post))
    time.sleep(3)
    print('posts updates')

if __name__=='__main__':
    sends()

橙子主题打折出售

其实我不卖,主要是这里是放广告的,所以就放了一个
毕竟主题都没做完,卖了也是坑.

购买它
所有附件
该文章没有附件.
本文为原创文章,请注意保留出处!

热门文章

WordPress 后台编辑器样式实现直接预览 在WordPress3.0以后,有一个新的实用功能:你可以更改默认后台编辑器(TinyMCE)的样...WordPress后台编辑器样式实现直接预览 作者:Pastore Antonio
1532 浏览量
【干货】Chrome插件(扩展)开发全攻略 写在前面我花了将近一个多月的时间断断续续写下这篇博文,并精心写下完整demo,写博客的辛苦大家懂的...【干货】Chrome插件(扩展)开发全攻略 作者:Pastore Antonio
1488 浏览量
memcached 处理 多端口:https://blog.csdn.net/Erica_1230/article/deta...memcached处理 作者:Pastore Antonio
1481 浏览量
使用Nginx+WordPress搭建个人网站 背景很多研究技术的朋友喜欢写博客。如果希望搭建一个完全属于自己的网站,也并不困难。这里简要分享一下...使用Nginx+WordPress搭建个人网站 作者:Pastore Antonio
1453 浏览量
C#图片处理 通常对一幅图片的处理包括:格式变换,缩放(Scale),翻转(Rotate),截取(Clip),滤镜...C#图片处理 作者:Pastore Antonio
1444 浏览量